浏览代码

修改四维看看复制过来的表名

wuweihao 5 年之前
父节点
当前提交
eb05b19f75

+ 2 - 2
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/CameraRepository.java

@@ -17,11 +17,11 @@ import java.util.List;
 @Component
 public interface CameraRepository extends IBaseRepository<CameraEntity, Long> {
 
-    @Select(value = "select * from tb_camera where wifi_name = #{code} and rec_status = 'A' ")
+    @Select(value = "select * from t_camera where wifi_name = #{code} and rec_status = 'A' ")
     CameraEntity findByWifiName(String code);
 
 
-    @Select(value = "select * from tb_camera z left join tb_camera_detail d on z.id = d.camera_id where " +
+    @Select(value = "select * from t_camera z left join t_camera_detail d on z.id = d.camera_id where " +
             "(z.sn_code like #{searchKey} or #{searchKey} is null)" +
 //            "(z.wifi_name like #{searchKey} or #{searchKey} is null)" +
             " and (d.user_id = #{userId} or #{userId} is null) " +

+ 2 - 0
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/ResourceRepository.java

@@ -2,10 +2,12 @@ package com.xiaoan.dao.backend;
 
 import com.xiaoan.domain.backend.ResourceEntity;
 import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
 
 /**
  * Created by owen on 2020/2/18 0018 11:13
  */
 @Mapper
+@Component
 public interface ResourceRepository extends IBaseRepository<ResourceEntity, Long> {
 }

+ 4 - 12
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/SceneRepository.java

@@ -25,26 +25,18 @@ import java.util.Map;
 @Mapper
 public interface SceneRepository extends IBaseRepository<SceneProEntity, Long> {
 
-//    @Select(value = "SELECT a.id,a.thumb,a.view_count AS viewCount,a.scene_name AS sceneName,a.create_time AS createTime,b.sn_code AS snCode,c.real_name AS realName FROM tb_scene_pro a LEFT JOIN tb_camera b ON a.camera_id = b.id LEFT JOIN tb_user c ON a.user_id = c.id WHERE 1=1 ")
-//    Page<Map<String, Object>> findSceneList(String searchKey, Date startTime, Date endTime, List<Long> ids, Pageable pageable);
+
 
     @SelectProvider(type = SceneProvider.class, method = "findAllBySearchKey")
     List<SceneResponse> findAllBySearchKey(SceneProRequest param, Long userId);
 
-    @Select(value = "select SUM(view_count) from tb_scene_pro where rec_status = 'A' ")
+    @Select(value = "select SUM(view_count) from t_scene_pro where rec_status = 'A' ")
     Integer findAllByViewCount();
 
-    @Select(value = "select id, thumb, view_count from tb_scene_pro where rec_status = 'A' ORDER BY view_count desc LIMIT #{num}")
+    @Select(value = "select id, thumb, view_count from t_scene_pro where rec_status = 'A' ORDER BY view_count desc LIMIT #{num}")
     List<SceneResponse> findAllByViewCountLimit(int num);
 
-    @Select(value = "select * from tb_scene_pro where rec_status = 'A' and status = '-2' and num = #{sceneNum}")
+    @Select(value = "select * from t_scene_pro where rec_status = 'A' and status = '-2' and num = #{sceneNum}")
     SceneProEntity findBySceneNum(String sceneNum);
 
-//    @SelectProvider(type = SceneProvider.class, method = "findAllBySearchKeyAndUserId")
-//    List<SceneResponse> findAllBySearchKeyAndUserId(SceneProRequest param, List<Long> ids, Long userId);
-
-
-//    @Select(value = "select * FROM tb_scene_pro z LEFT JOIN tb_user u ON z.user_id = u.id where (z.create_time <= #{startTime} and z.create_time >= #{endTime}) or" +
-//            "(u.real_name like #{searchKey} or #{searchKey} is null) or (z.scene_name like #{searchKey} or #{searchKey} is null) order by create_time desc " )
-//    List<SceneResponse> searchFindAllBySearchKey(String searchKey, String startTime, String endTime);
 }

+ 1 - 45
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/provider/SceneProvider.java

@@ -16,7 +16,7 @@ public class  SceneProvider {
     public String findAllBySearchKey(SceneProRequest param, Long userId){
         StringBuffer sql = new StringBuffer("SELECT a.id, a.thumb, a.view_count, " +
                 "a.scene_name, a.create_time, b.sn_code, c.real_name " +
-                "FROM tb_scene_pro a LEFT JOIN tb_camera b ON a.camera_id = b.id " +
+                "FROM t_scene_pro a LEFT JOIN t_camera b ON a.camera_id = b.id " +
                 "LEFT JOIN tb_user c ON a.user_id = c.id where a.rec_status = 'A' ");
 
         if(StringUtils.isNotBlank(param.getStartTime()) && StringUtils.isNotBlank(param.getEndTime())){
@@ -61,48 +61,4 @@ public class  SceneProvider {
     }
 
 
-    /**
-     * 根据用户模糊查询
-     * @param param
-     * @param ids
-     * @return
-     */
-//    public String findAllBySearchKeyAndUserId(SceneProRequest param, List<Long> ids, Long userId){
-//        StringBuffer sql = new StringBuffer("SELECT a.id, a.thumb, a.view_count, " +
-//                "a.scene_name, a.create_time, b.sn_code, c.real_name " +
-//                "FROM tb_scene_pro a LEFT JOIN tb_camera b ON a.camera_id = b.id " +
-//                "LEFT JOIN tb_user c ON a.user_id = c.id where a.rec_status = 'A' ");
-//
-//        if (userId != null) {
-//            sql.append(" and a.user_id = ").append(userId);
-//        }
-//
-//        if(StringUtils.isNotBlank(param.getStartTime()) && StringUtils.isNotBlank(param.getEndTime())){
-//            sql.append(" and a.create_time >= ").append("'").append(param.getStartTime()).append("'");
-//            sql.append(" and a.create_time <= ").append("'").append(param.getEndTime()).append("'");
-//        }
-//
-//        if(StringUtils.isNotEmpty(param.getSearchKey())){
-//            sql.append("or a.scene_name like '%").append(param.getSearchKey()).append("%'");
-//            sql.append("or c.real_name like '%").append(param.getSearchKey()).append("%'");
-//        }
-//        if(ids != null && ids.size() > 0){
-//            sql.append(" and c.id in(");
-//            for(int i = 0, len = ids.size(); i < len; i ++){
-//                if(i == len){
-//                    sql.append(ids.get(i));
-//                }else {
-//                    sql.append(ids.get(i)).append(",");
-//                }
-//            }
-//            sql.append(" )");
-//        }
-//        if(param.getStatus() != null){
-//            sql.append(" and a.status = ").append(param.getStatus());
-//        }
-//
-//        sql.append(" order by create_time desc");
-//        return sql.toString();
-//    }
-
 }

+ 1 - 1
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/CameraDetailEntity.java

@@ -12,7 +12,7 @@ import java.math.BigInteger;
  * 相机实体表
  */
 @Data
-@Table(name = "tb_camera_detail")
+@Table(name = "t_camera_detail")
 public class CameraDetailEntity extends BaseModel implements Serializable {
 
     private static final long serialVersionUID = -122990405139092098L;

+ 1 - 1
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/CameraEntity.java

@@ -12,7 +12,7 @@ import java.util.Date;
  * 相机实体表
  */
 @Data
-@Table(name = "tb_camera")
+@Table(name = "t_camera")
 public class CameraEntity extends BaseModel implements Serializable {
 
     private static final long serialVersionUID = 6384935760157228272L;

+ 8 - 65
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/ResourceEntity.java

@@ -1,10 +1,13 @@
 package com.xiaoan.domain.backend;
 
+import com.alibaba.fastjson.annotation.JSONField;
 import com.xiaoan.common.model.BaseModel;
+import lombok.Data;
 
 import javax.persistence.*;
 import java.io.Serializable;
 
+@Data
 @Entity
 @Table(name = "tb_resource")
 public class ResourceEntity extends BaseModel implements Serializable {
@@ -18,15 +21,18 @@ public class ResourceEntity extends BaseModel implements Serializable {
     private String name;
 
     // 描述
+    @JSONField(serialize = false)
     @Column(name = "description")
     private String description;
 
+    @JSONField(serialize = false)
     @Column(name = "url")
     private String url;
 
-    @Column(length = 10)
-    private String icon;
+//    @Column(length = 10)
+//    private String icon;
 
+    @JSONField(serialize = false)
     @Column(name = "resource_key")
     private String resourceKey;
 
@@ -40,68 +46,5 @@ public class ResourceEntity extends BaseModel implements Serializable {
     @Column(name = "parent_id")
     private Long parentId;
 
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-//    public String getDescription() {
-//        return description;
-//    }
-//
-//    public void setDescription(String description) {
-//        this.description = description;
-//    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-//    public String getIcon() {
-//        return icon;
-//    }
-//
-//    public void setIcon(String icon) {
-//        this.icon = icon;
-//    }
-
-    public String getResourceType() {
-        return resourceType;
-    }
-
-    public void setResourceType(String resourceType) {
-        this.resourceType = resourceType;
-    }
-
-    public Long getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(Long parentId) {
-        this.parentId = parentId;
-    }
-
-    public String getResourceKey() {
-        return resourceKey;
-    }
-
-    public void setResourceKey(String resourceKey) {
-        this.resourceKey = resourceKey;
-    }
-
-    public Byte getSort() {
-        return sort;
-    }
-
-    public void setSort(Byte sort) {
-        this.sort = sort;
-    }
 
 }

+ 1 - 1
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/SceneProEditEntity.java

@@ -13,7 +13,7 @@ import java.io.Serializable;
  */
 @Data
 @Entity
-@Table(name = "tb_scene_pro_edit")
+@Table(name = "t_scene_pro_edit")
 public class SceneProEditEntity extends BaseModel implements Serializable {
 
     private static final long serialVersionUID = 661912133849676944L;

+ 1 - 1
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/SceneProEntity.java

@@ -14,7 +14,7 @@ import java.math.BigInteger;
  */
 @Data
 @Entity
-@Table(name = "tb_scene_pro")
+@Table(name = "t_scene_pro")
 public class SceneProEntity extends BaseModel implements Serializable {
 
     private static final long serialVersionUID = 661912133849676944L;

+ 117 - 105
xiaoan-service/src/main/java/com/xiaoan/service/backend/dto/ResourceTree.java

@@ -1,7 +1,11 @@
 package com.xiaoan.service.backend.dto;
 
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
 import java.util.List;
 
+@Data
 public class ResourceTree {
 
     private Long id;
@@ -10,129 +14,137 @@ public class ResourceTree {
 
     private Long parentId;
 
+    @JSONField(serialize = false)
     private boolean checked = false;
 
+    @JSONField(serialize = false)
     private boolean spread = false;
 
+    @JSONField(serialize = false)
     private String isHeader = "0";
 
+    @JSONField(serialize = false)
     private String url;
 
+    @JSONField(serialize = false)
     private String icon;
 
+    @JSONField(serialize = false)
     private String resourceKey;
 
     private String resourceType;
 
+    @JSONField(serialize = false)
     private String order = "1";
 
     private List<ResourceTree> children;
 
+    @JSONField(serialize = false)
     private int level;
 
-    public Long getId() {
-        return id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public List<ResourceTree> getChildren() {
-        return children;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public void setChildren(List<ResourceTree> children) {
-        this.children = children;
-    }
-
-    public Long getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(Long parentId) {
-        this.parentId = parentId;
-    }
-
-    public boolean isChecked() {
-        return checked;
-    }
-
-    public void setChecked(boolean checked) {
-        this.checked = checked;
-        this.spread = checked;
-    }
-
-    public boolean isSpread() {
-        return spread;
-    }
-
-    public void setSpread(boolean spread) {
-        this.spread = spread;
-    }
-
-
-    public String getIsHeader() {
-        return isHeader;
-    }
-
-    public void setIsHeader(String isHeader) {
-        this.isHeader = isHeader;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getIcon() {
-        return icon;
-    }
-
-    public void setIcon(String icon) {
-        this.icon = icon;
-    }
-
-    public String getOrder() {
-        return order;
-    }
-
-    public void setOrder(String order) {
-        this.order = order;
-    }
-
-    public int getLevel() {
-        return level;
-    }
-
-    public void setLevel(int level) {
-        this.level = level;
-    }
-
-    public String getResourceType() {
-        return resourceType;
-    }
-
-    public void setResourceType(String resourceType) {
-        this.resourceType = resourceType;
-    }
-
-    public String getResourceKey() {
-        return resourceKey;
-    }
-
-    public void setResourceKey(String resourceKey) {
-        this.resourceKey = resourceKey;
-    }
+//    public Long getId() {
+//        return id;
+//    }
+//
+//    public String getName() {
+//        return name;
+//    }
+//
+//    public List<ResourceTree> getChildren() {
+//        return children;
+//    }
+//
+//    public void setId(Long id) {
+//        this.id = id;
+//    }
+//
+//    public void setName(String name) {
+//        this.name = name;
+//    }
+//
+//    public void setChildren(List<ResourceTree> children) {
+//        this.children = children;
+//    }
+//
+//    public Long getParentId() {
+//        return parentId;
+//    }
+//
+//    public void setParentId(Long parentId) {
+//        this.parentId = parentId;
+//    }
+//
+//    public boolean isChecked() {
+//        return checked;
+//    }
+//
+//    public void setChecked(boolean checked) {
+//        this.checked = checked;
+//        this.spread = checked;
+//    }
+//
+//    public boolean isSpread() {
+//        return spread;
+//    }
+//
+//    public void setSpread(boolean spread) {
+//        this.spread = spread;
+//    }
+//
+//
+//    public String getIsHeader() {
+//        return isHeader;
+//    }
+//
+//    public void setIsHeader(String isHeader) {
+//        this.isHeader = isHeader;
+//    }
+//
+//    public String getUrl() {
+//        return url;
+//    }
+//
+//    public void setUrl(String url) {
+//        this.url = url;
+//    }
+//
+//    public String getIcon() {
+//        return icon;
+//    }
+//
+//    public void setIcon(String icon) {
+//        this.icon = icon;
+//    }
+//
+//    public String getOrder() {
+//        return order;
+//    }
+//
+//    public void setOrder(String order) {
+//        this.order = order;
+//    }
+//
+//    public int getLevel() {
+//        return level;
+//    }
+//
+//    public void setLevel(int level) {
+//        this.level = level;
+//    }
+//
+//    public String getResourceType() {
+//        return resourceType;
+//    }
+//
+//    public void setResourceType(String resourceType) {
+//        this.resourceType = resourceType;
+//    }
+//
+//    public String getResourceKey() {
+//        return resourceKey;
+//    }
+//
+//    public void setResourceKey(String resourceKey) {
+//        this.resourceKey = resourceKey;
+//    }
 }

+ 4 - 3
xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/ResourceServiceImpl.java

@@ -47,7 +47,7 @@ public class ResourceServiceImpl extends BaseServiceImpl<ResourceEntity, Long> i
      * @throws Exception
      */
     @Override
-    @Cacheable(value = "resourcesUserCache", key = "#root.caches[0].name + ':' + #user.id")
+//    @Cacheable(value = "resourcesUserCache", key = "#root.caches[0].name + ':' + #user.id")
     public List<ResourceTree> getResourcesTreeByUserMenu(UserEntity userEntity) throws Exception {
         //Get userEntity menu
 
@@ -68,7 +68,8 @@ public class ResourceServiceImpl extends BaseServiceImpl<ResourceEntity, Long> i
             }
         }
         ResourceTreeUtil tree = new ResourceTreeUtil(resourcesUserMenu);
-        return tree.buildTree();
+        List<ResourceTree> resourceTrees = tree.buildTree();
+        return resourceTrees;
     }
 
     /**
@@ -84,7 +85,7 @@ public class ResourceServiceImpl extends BaseServiceImpl<ResourceEntity, Long> i
     }
 
     @Override
-    @Cacheable(value = "resourcesCache")
+//    @Cacheable(value = "resourcesCache")
     public List<ResourceTree> getTree() throws Exception {
         List<ResourceEntity> resourceEntities = resourceRepository.selectAll();
         ResourceTreeUtil tree = new ResourceTreeUtil(resourceEntities);

+ 1 - 1
xiaoan-service/src/main/java/com/xiaoan/service/backend/util/ResourceTreeUtil.java

@@ -40,7 +40,7 @@ public class ResourceTreeUtil {
     public List<ResourceTree> buildTree() {
         for (ResourceTree node : nodes) {
             Long id = node.getParentId();
-            if (node.getParentId() == null) {//通过循环一级节点 就可以通过递归获取二级以下节点
+            if (id == null) {//通过循环一级节点 就可以通过递归获取二级以下节点
                 resultNodes.add(node);//添加一级节点
 //                node.setLevel(1);
                 build(node, node.getLevel());//递归获取二级、三级、。。。节点

+ 3 - 21
xiaoan-web/src/main/java/com/xiaoan/web/backend/IndexController.java

@@ -38,9 +38,6 @@ public class IndexController {
     private UserService userService;
 
     @Autowired
-    private RoleService roleService;
-
-    @Autowired
     private ResourceService resourceService;
 
     @Autowired
@@ -83,18 +80,15 @@ public class IndexController {
         tokenMap.put("id", userEntity.getId());
         tokenMap.put("role", roles);
 
-//        String token = JWTUtil.sign(tokenMap, userEntity.getPassword());
 
         String token = JwtUtil2.createJWT(-1, tokenMap);
 //
-//        String token = JWTUtil.sign(param.getUserName(), userEntity.getPassword());
-//        log.warn("new token: {}", token);
 
         HashMap<String, Object> result = new HashMap<>();
         result.put("user", userEntity);
-//        result.put("resources", resourcesByUserMenu);
         result.put("token", token);
-        result.put("permission", resourcesTreeByUserPermission);
+//        result.put("permission", resourcesTreeByUserPermission);
+        result.put("permission", resourcesByUserMenu);
 
 
         // 更新到 redis, 有效期24h, 旧token无效
@@ -114,10 +108,9 @@ public class IndexController {
 
     @GetMapping("admin/logout")
     public ResultJson logout(HttpServletRequest request) {
-        log.info("run logout");
 
         String token = request.getHeader("Authorization");
-        String username = JWTUtil.getUsername(token);
+        String username = JwtUtil2.getUsername(token);
 
         String redisToken = (String) redisTemplate.opsForValue().get(username);
         // token username 一致,代表没有被踢出
@@ -125,18 +118,7 @@ public class IndexController {
             redisTemplate.delete(username);
         }
 
-        log.info("end logout");
         return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
     }
 
-    public static void main(String[] args) {
-        int a = 0;
-        for (int i = 0; i < 10; i++) {
-
-            a++;
-        }
-
-        System.out.println(a);
-
-    }
 }

+ 2 - 1
xiaoan-web/src/main/java/com/xiaoan/web/backend/ResourceController.java

@@ -10,6 +10,7 @@ import com.xiaoan.service.backend.ResourceService;
 import com.xiaoan.service.backend.dto.ResourceTree;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -27,7 +28,7 @@ import java.util.List;
 @Api(tags = "ResourceController", description = "后台资源管理")
 @RestController
 @RequestMapping("api/manage/resource")
-//@RequiresRoles("admin") //需要admin角色才可以访问此controller
+@RequiresRoles("admin") //需要admin角色才可以访问此controller
 public class ResourceController {
 
     @Autowired

+ 50 - 75
xiaoan-web/src/main/java/com/xiaoan/web/backend/RoleController.java

@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Sort;
@@ -37,23 +38,14 @@ import java.util.List;
 @RestController
 @RequestMapping("api/manage/role")
 @Transactional
-//@RequiresRoles("admin") //需要admin角色才可以访问此controller
+@RequiresRoles("admin") //需要admin角色才可以访问此controller
 public class RoleController extends BaseController {
 
     @Autowired
     private RoleService roleService;
 
-    @Autowired
-    private RoleRepository roleRepository;
-
-    @WebControllerLog(description = "角色权限-查询列表")
+        @WebControllerLog(description = "角色权限-查询列表")
     @ApiOperation("分页获取角色列表/搜索")
-//    @PostMapping("list")
-//    public ResultJson list(@RequestBody RoleRequest param){
-//        PageInfo<RoleEntity> pageInfo = roleService.findAll(param.getPageNum(), param.getPageSize());
-//        return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
-//    }
-
     @PostMapping("list")
     public ResultJson list(@RequestBody PageDto param){
         Condition condition = new Condition(RoleEntity.class);
@@ -63,7 +55,7 @@ public class RoleController extends BaseController {
         return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
     }
 
-//    @RequiresRoles("admin")
+
     @ApiOperation("获取角色")
     @GetMapping("find")
     public ResultJson find(){
@@ -71,64 +63,8 @@ public class RoleController extends BaseController {
         return new ResultJson(MsgCode.SUCCESS_CODE, result);
     }
 
-    @ApiOperation("新增或修改角色信息")
-    @PostMapping("save")
-    public ResultJson save(@RequestBody RoleRequest param){
-//        RoleEntity roleEntity = null;
-//        int n = 0;
-//        if (param.getId() != null) {
-//            roleEntity = roleService.findById(param.getId());
-//            if(roleEntity == null){
-//                return new ResultJson(MsgCode.FAILURE_CODE_6001, MsgCode.FAILURE_MSG_6001);
-//            }
-//            // 每次修改,删除角色资源表信息,重新添加
-//            roleService.deleteRoleResource(param.getId());
-//
-//            BeanUtils.copyProperties(param, roleEntity);
-//            n = roleService.update(roleEntity);
-//        }else {
-//            roleEntity = new RoleEntity();
-//
-//            BeanUtils.copyProperties(param, roleEntity);
-//            roleEntity.setUpdateTime(new Date());
-//
-//
-//            n = roleService.save(roleEntity);
-//        }
-
-        RoleEntity roleEntity = roleService.findById(param.getId());
-
-        int n = 0;
-
-        if (roleEntity == null) {
-            roleEntity = new RoleEntity();
-            // 保存的时候,如果有id,会出错
-            param.setId(null);
-            BeanUtils.copyProperties(param, roleEntity);
-            n = roleService.save(roleEntity);
-
-        } else {
-            BeanUtils.copyProperties(param, roleEntity);
-            roleEntity.setUpdateTime(new Date());
-            n = roleService.update(roleEntity);
-
-            // 每次修改,删除角色资源表信息,重新添加
-            roleService.deleteRoleResource(param.getId());
-        }
-
-        if (n >= 0){
-            if (param.getResources() != null){
-                for (long i : param.getResources()) {
-                    roleService.saveRoleResource(roleEntity.getId(), i);
-                }
-                return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
-            }
-        }
 
-        return new ResultJson(MsgCode.ERROR_CODE, MsgCode.ERROR_MSG);
-    }
 
-    //测试权限
 
     @ApiOperation("查询角色信息")
     @GetMapping("detail/{id}")
@@ -137,13 +73,6 @@ public class RoleController extends BaseController {
         return new ResultJson(MsgCode.SUCCESS_CODE, roleEntity);
     }
 
-    @ApiOperation("删除角色")
-    @GetMapping("delete/{id}")
-    public ResultJson delete(@PathVariable Long id){
-        roleService.deleteById(id);
-//        roleService.deleteRoleResource(id);
-        return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
-    }
 
     /**
      * 测试权限用
@@ -173,6 +102,52 @@ public class RoleController extends BaseController {
     }
 
 
+    /**
+     * 角色直接从数据库管理,因为前端不做资源管理,所以不提供新增、修改、删除,只提供查询
+     */
+//    @ApiOperation("新增或修改角色信息")
+//    @PostMapping("save")
+//    public ResultJson save(@RequestBody RoleRequest param){
+//        RoleEntity roleEntity = roleService.findById(param.getId());
+//
+//        int n = 0;
+//
+//        if (roleEntity == null) {
+//            roleEntity = new RoleEntity();
+//            // 保存的时候,如果有id,会出错
+//            param.setId(null);
+//            BeanUtils.copyProperties(param, roleEntity);
+//            n = roleService.save(roleEntity);
+//
+//        } else {
+//            BeanUtils.copyProperties(param, roleEntity);
+//            roleEntity.setUpdateTime(new Date());
+//            n = roleService.update(roleEntity);
+//
+//            // 每次修改,删除角色资源表信息,重新添加
+//            roleService.deleteRoleResource(param.getId());
+//        }
+//
+//        if (n >= 0){
+//            if (param.getResources() != null){
+//                for (long i : param.getResources()) {
+//                    roleService.saveRoleResource(roleEntity.getId(), i);
+//                }
+//                return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
+//            }
+//        }
+//
+//        return new ResultJson(MsgCode.ERROR_CODE, MsgCode.ERROR_MSG);
+//    }
+
+//    @ApiOperation("删除角色")
+//    @GetMapping("delete/{id}")
+//    public ResultJson delete(@PathVariable Long id){
+//        roleService.deleteById(id);
+////        roleService.deleteRoleResource(id);
+//        return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
+//    }
+