角色/权限管理

This commit is contained in:
x ronger 2019-12-05 20:02:13 +08:00
parent 2798408108
commit e2366a91a1
3 changed files with 6 additions and 2 deletions

View File

@ -14,4 +14,6 @@ public interface RoleMapper extends Mapper<Role> {
Role selectRoleByInputCode(@Param("inputCode") String inputCode); Role selectRoleByInputCode(@Param("inputCode") String inputCode);
Integer updateStatus(@Param("idRole") Integer idRole, @Param("status") String status); Integer updateStatus(@Param("idRole") Integer idRole, @Param("status") String status);
Integer update(@Param("idRole") Integer idRole, @Param("name") String name, @Param("inputCode") String inputCode, @Param("weights") Integer weights);
} }

View File

@ -51,13 +51,12 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
public Map saveRole(Role role) { public Map saveRole(Role role) {
Integer result = 0; Integer result = 0;
if (role.getIdRole() == null) { if (role.getIdRole() == null) {
role.setStatus("0");
role.setCreatedTime(new Date()); role.setCreatedTime(new Date());
role.setUpdatedTime(role.getCreatedTime()); role.setUpdatedTime(role.getCreatedTime());
result = roleMapper.insertSelective(role); result = roleMapper.insertSelective(role);
} else { } else {
role.setCreatedTime(new Date()); role.setCreatedTime(new Date());
result = roleMapper.updateByPrimaryKeySelective(role); result = roleMapper.update(role.getIdRole(),role.getName(),role.getInputCode(),role.getWeights());
} }
Map map = new HashMap(1); Map map = new HashMap(1);
if (result == 0) { if (result == 0) {

View File

@ -16,6 +16,9 @@
<update id="updateStatus"> <update id="updateStatus">
update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole} update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole}
</update> </update>
<update id="update">
update vertical_role set name = #{name}, input_code = ${inputCode}, weights = #{weights}, updated_time = sysdate() where id = #{idRole}
</update>
<select id="selectRoleByIdUser" resultMap="BaseResultMap"> <select id="selectRoleByIdUser" resultMap="BaseResultMap">
select sr.* from vertical_user_role sur left join vertical_role sr on sur.id_role = sr.id where id_user = #{id} select sr.* from vertical_user_role sur left join vertical_role sr on sur.id_role = sr.id where id_user = #{id}