wangning 6 years ago
parent 103ca68c2d
commit 36cac76a91

@ -0,0 +1,8 @@
package au.com.royalpay.payment.manage.management.sysconfig.beans;
/**
* @author kira
* @date 2018/7/4
*/
public class PermissionClientVO {
}

@ -0,0 +1,38 @@
package au.com.royalpay.payment.manage.management.sysconfig.web;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.system.core.PermissionClientMoudulesService;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import javax.annotation.Resource;
/**
* Created by yixian on 2017-02-28.
*/
@RestController
@ManagerMapping(role = ManagerRole.ADMIN, value = "/sys/permission")
public class SysPermissionClientController {
@Resource
private PermissionClientMoudulesService permissionClientMoudulesService;
@RequestMapping(value = "/client/{client_id}/list", method = RequestMethod.GET)
public List<JSONObject> list(@PathVariable int client_id) {
return permissionClientMoudulesService.listByClientId(client_id);
}
@RequestMapping(value = "/client/{client_id}", method = RequestMethod.POST)
public List<JSONObject> modify(@PathVariable int client_id,) {
return permissionClientMoudulesService.listByClientId(client_id);
}
}

@ -0,0 +1,32 @@
package au.com.royalpay.payment.manage.mappers.system;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yixian on 2017-02-28.
*/
@AutoMapper(tablename = "sys_permission_client_moudules", pkName = "id")
public interface SysPermissionClientMoudulesMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject module);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject module);
@AutoSql(type = SqlType.DELETE)
void delete(@Param("id") Long id);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> listByClientId(@Param("client_id") int client_id);
@AutoSql(type = SqlType.SELECT)
JSONObject find(@Param("id") Long id);
}

@ -0,0 +1,20 @@
package au.com.royalpay.payment.manage.system.core;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
/**
* @author kira
* @date 2018/7/4
*/
public interface PermissionClientMoudulesService {
void save(JSONObject record);
List<JSONObject> listByClientId(int clientId);
void switchValid(Long id,boolean isValid,JSONObject account);
}

@ -0,0 +1,98 @@
package au.com.royalpay.payment.manage.system.core.beans;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
* @author kira
* @date 2018/7/4
*/
@Document(collection = "permission_client_moudule_log")
public class PermissionClientMouduleLog {
private long id;
private int clientId;
private String clientMoniker;
private String business;
private String userId;
private String userName;
private String originData;
private String newData;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+10")
private Date createTime;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getClientId() {
return clientId;
}
public void setClientId(int clientId) {
this.clientId = clientId;
}
public String getClientMoniker() {
return clientMoniker;
}
public void setClientMoniker(String clientMoniker) {
this.clientMoniker = clientMoniker;
}
public String getBusiness() {
return business;
}
public void setBusiness(String business) {
this.business = business;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getOriginData() {
return originData;
}
public void setOriginData(String originData) {
this.originData = originData;
}
public String getNewData() {
return newData;
}
public void setNewData(String newData) {
this.newData = newData;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

@ -0,0 +1,76 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.mappers.system.SysPermissionClientMoudulesMapper;
import au.com.royalpay.payment.manage.system.core.PermissionClientMoudulesService;
import au.com.royalpay.payment.manage.system.core.beans.PermissionClientMouduleLog;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.utils.id.IdUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/7/4
*/
@Service
public class PermissionClientMoudulesServiceImpl implements PermissionClientMoudulesService {
@Resource
private SysPermissionClientMoudulesMapper permissionClientMoudulesMapper;
@Resource
private MongoTemplate mongoTemplate;
@Override
public void save(JSONObject record) {
record.put("id",IdUtil.getId());
permissionClientMoudulesMapper.save(record);
}
@Override
public List<JSONObject> listByClientId(int clientId) {
return permissionClientMoudulesMapper.listByClientId(clientId);
}
@Override
public void switchValid(Long id, boolean isValid, JSONObject account) {
JSONObject record = permissionClientMoudulesMapper.find(id);
if (record == null) {
throw new NotFoundException("Permission Client Moudule Not Found id:" + id);
}
JSONObject updateRecord = new JSONObject();
updateRecord.put("is_valid", isValid);
updateRecord.put("id", record.getLong("id"));
saveMongoLog(account,record,updateRecord,(isValid?"打开":"关闭")+"模块 id:"+record.getString("module_id"));
permissionClientMoudulesMapper.update(updateRecord);
}
private void saveMongoLog(JSONObject account, JSONObject oldRecord, JSONObject modifyData, String business) {
modifyData.remove("id");
PermissionClientMouduleLog mongoRecord = new PermissionClientMouduleLog();
mongoRecord.setBusiness(business);
mongoRecord.setClientId(oldRecord.getIntValue("client_id"));
mongoRecord.setClientMoniker(oldRecord.getString("client_moniker"));
mongoRecord.setCreateTime(new Date());
mongoRecord.setId(IdUtil.getId());
mongoRecord.setUserId(account.getString("manager_id"));
mongoRecord.setUserName(account.getString("display_name"));
mongoRecord.setNewData(modifyData.toJSONString());
Map<String, Object> beforeModify = modifyData.keySet().stream().collect(Collectors.toMap(key -> key, oldRecord::get));
mongoRecord.setOriginData(JSON.toJSONString(beforeModify));
mongoTemplate.insert(mongoRecord);
}
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.SysPermissionClientMoudulesMapper">
<sql id="joinModule">
SELECT
f.*,
m.js_module,
m.js_path,
m.remark mod_remark
FROM sys_permission_functions f
LEFT JOIN sys_permission_modules m ON m.module_name = f.module
</sql>
</mapper>
Loading…
Cancel
Save