Merge remote-tracking branch 'origin/master'

master
赵玉瑞 2 years ago
commit fbedf10989
  1. 24
      ant-design-vue-jeecg/src/views/fieldx/FieldxList.vue
  2. 11
      ant-design-vue-jeecg/src/views/fieldx/modules/FieldxForm.vue
  3. 21
      ant-design-vue-jeecg/src/views/tablex/TablexList.vue
  4. 20
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java
  5. 51
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  6. 67
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  7. 12
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java
  8. 2
      jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml
  9. 2
      jeecg-boot/jeecg-boot-module-system/src/main/resources/application-prod.yml

@ -138,7 +138,7 @@
} }
}, },
{ {
title:'对应实体id', title:'对应实体',
align:"center", align:"center",
dataIndex: 'tableId_dictText' dataIndex: 'tableId_dictText'
}, },
@ -245,8 +245,9 @@
} }
}, },
created() { created() {
this.getSuperFieldList();
this.loadParameter(); this.loadParameter();
this.getSuperFieldList();
this.searchQuery();
}, },
computed: { computed: {
importExcelUrl: function(){ importExcelUrl: function(){
@ -256,17 +257,30 @@
methods: { methods: {
initDictConfig(){ initDictConfig(){
}, },
searchReset() {
this.tableId = this.$route.query.tableId;
this.queryParam ={};
this.queryParam.tableId = this.tableId;
this.loadData(1);
},
searchQuery(){
this.tableId = this.$route.query.tableId;
this.queryParam.tableId = this.$route.query.tableId;
this.loadData(1);
},
// //
loadParameter() { loadParameter() {
if (this.loadRouteType == false) { if (this.loadRouteType == false) {
this.tableId = this.$route.query.id; this.queryParam.tableId = this.$route.query.tableId;
console.log(this.tableId) this.tableId = this.$route.query.tableId;
console.log(this.queryParam.tableId)
this.loadRouteType = true; this.loadRouteType = true;
this.loadData(1);
} }
}, },
getSuperFieldList(){ getSuperFieldList(){
let fieldList=[]; let fieldList=[];
fieldList.push({type:'string',value:'tableId',text:'对应实体id',dictCode:'tablex,table_name,id'}) fieldList.push({type:'string',value:'tableId',text:'对应实体',dictCode:'tablex,table_name,id'})
fieldList.push({type:'string',value:'fieldName',text:'中文名称',dictCode:''}) fieldList.push({type:'string',value:'fieldName',text:'中文名称',dictCode:''})
fieldList.push({type:'string',value:'fieldEnName',text:'英文名称',dictCode:''}) fieldList.push({type:'string',value:'fieldEnName',text:'英文名称',dictCode:''})
fieldList.push({type:'sel_search',value:'type',text:'数据类型',dictTable:'', dictText:'', dictCode:'date_type'}) fieldList.push({type:'sel_search',value:'type',text:'数据类型',dictTable:'', dictText:'', dictCode:'date_type'})

@ -50,12 +50,12 @@
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-model-item label="关联实体" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="associateTable"> <a-form-model-item label="关联实体" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="associateTable">
<j-search-select-tag v-model="model.associateTable" dict="tablex,table_name,id" ></j-search-select-tag> <j-search-select-tag v-model="model.associateTable" dict="tablex,table_name,id" @change="ziduan" ></j-search-select-tag>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-model-item label="关联字段" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="associateField"> <a-form-model-item label="关联字段" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="associateField">
<j-search-select-tag v-model="model.associateField" placeholder="请输入关联字段" dict="fieldx,field_name,id"></j-search-select-tag> <j-search-select-tag v-model="model.associateField" placeholder="请输入关联字段" :dict=field></j-search-select-tag>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
@ -163,7 +163,8 @@
add: "/fieldx/fieldx/add", add: "/fieldx/fieldx/add",
edit: "/fieldx/fieldx/edit", edit: "/fieldx/fieldx/edit",
queryById: "/fieldx/fieldx/queryById" queryById: "/fieldx/fieldx/queryById"
} },
field:'fieldx,field_name,id',
} }
}, },
computed: { computed: {
@ -176,6 +177,10 @@
this.modelDefault = JSON.parse(JSON.stringify(this.model)); this.modelDefault = JSON.parse(JSON.stringify(this.model));
}, },
methods: { methods: {
ziduan(){
this.field="fieldx,field_name,id,table_id="+this.model.associateTable;
this.model.associateField = '';
},
add () { add () {
this.edit(this.modelDefault); this.edit(this.modelDefault);
}, },

@ -88,9 +88,11 @@
</a-button> </a-button>
</template> </template>
<template slot="htmlSlot" slot-scope="text,record">
<a @click="tablemanage(record.id)">字段</a>
</template>
<span slot="action" slot-scope="text, record"> <span slot="action" slot-scope="text, record">
<a @click="tablemanage(record.id)">实体管理</a>
<a-divider type="vertical" />
<a @click="handleEdit(record)">编辑</a> <a @click="handleEdit(record)">编辑</a>
@ -165,7 +167,8 @@
{ {
title:'结构图', title:'结构图',
align:"center", align:"center",
dataIndex: 'structuralDiagram' dataIndex: 'structuralDiagram',
scopedSlots: {customRender: 'imgSlot'}
}, },
{ {
title:'创建人', title:'创建人',
@ -202,6 +205,14 @@
align:"center", align:"center",
dataIndex: 'verison' dataIndex: 'verison'
}, },
{
title: '管理',
dataIndex: 'htmlSlot',
align: "center",
fixed: "right",
width: 147,
scopedSlots: {customRender: 'htmlSlot'}
},
{ {
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
@ -232,10 +243,10 @@
}, },
}, },
methods: { methods: {
tablemanage(id) { tablemanage(tableId) {
this.$router.push({ this.$router.push({
path: '/fieldx/FieldxList', path: '/fieldx/FieldxList',
query: {id: id} query: {tableId: tableId}
}) })
}, },
initDictConfig(){ initDictConfig(){

@ -87,6 +87,9 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<?> add(@RequestBody Fieldx fieldx) { public Result<?> add(@RequestBody Fieldx fieldx) {
fieldx.setVerison(1); fieldx.setVerison(1);
if (fieldx.getAssociateTable() != null && fieldx.getAssociateTable().equals(fieldx.getTableId())){
return Result.error("实体不能关联自身,添加失败");
}
if (fieldx.getTableId() != null){ if (fieldx.getTableId() != null){
List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", fieldx.getTableId())); List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", fieldx.getTableId()));
for (Fieldx fieldx1 : fieldxList){ for (Fieldx fieldx1 : fieldxList){
@ -116,6 +119,23 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
@ApiOperation(value="字段管理-编辑", notes="字段管理-编辑") @ApiOperation(value="字段管理-编辑", notes="字段管理-编辑")
@PutMapping(value = "/edit") @PutMapping(value = "/edit")
public Result<?> edit(@RequestBody Fieldx fieldx) { public Result<?> edit(@RequestBody Fieldx fieldx) {
if (fieldx.getAssociateTable() != null && fieldx.getAssociateTable().equals(fieldx.getTableId())){
return Result.error("实体不能关联自身,编辑失败");
}
if (fieldx.getTableId() != null){
List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", fieldx.getTableId()));
for (Fieldx fieldx1 : fieldxList){
if (fieldx1.getFieldName().equals(fieldx.getFieldName())){
return Result.error("编辑失败,所属实体已有该中文名称");
}
if (fieldx1.getFieldEnName().equals(fieldx.getFieldEnName())){
return Result.error("编辑失败,所属实体已有该英文名称");
}
if (fieldx.getIsPk() == 1 && fieldx1.getIsPk() == 1){
return Result.error("该实体已经有主键,编辑失败");
}
}
}
fieldxService.updateById(fieldx); fieldxService.updateById(fieldx);
tablexService.updateSql(fieldx.getTableId(),createSql(fieldx.getTableId())); tablexService.updateSql(fieldx.getTableId(),createSql(fieldx.getTableId()));
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");

@ -14,18 +14,19 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.aspect.annotation.PermissionData; import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*; import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.model.DepartIdModel; import org.jeecg.modules.system.model.DepartIdModel;
import org.jeecg.modules.system.model.SysUserSysDepartModel; import org.jeecg.modules.system.model.SysUserSysDepartModel;
@ -57,7 +58,7 @@ import java.util.stream.Collectors;
* </p> * </p>
* *
* @Author scott * @Author scott
* @since 2018-12-20 * @since 2023-04-12
*/ */
@Slf4j @Slf4j
@RestController @RestController
@ -98,6 +99,7 @@ public class SysUserController {
/** /**
* 获取用户列表数据 * 获取用户列表数据
*
* @param user * @param user
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
@ -155,6 +157,7 @@ public class SysUserController {
/** /**
* 获取员工列表数据 * 获取员工列表数据
*
* @param user * @param user
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
@ -191,12 +194,12 @@ public class SysUserController {
//@RequiresRoles({"admin"}) //@RequiresRoles({"admin"})
//@RequiresPermissions("user:add") //@RequiresPermissions("user:add")
@AutoLog
@RequestMapping(value = "/add", method = RequestMethod.POST) @RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysUser> add(@RequestBody JSONObject jsonObject) { public Result<SysUser> add(@RequestBody JSONObject jsonObject) {
Result<SysUser> result = new Result<SysUser>(); Result<SysUser> result = new Result<SysUser>();
String selectedRoles = jsonObject.getString("selectedroles"); String selectedRoles = jsonObject.getString("selectedroles");
String selectedDeparts = jsonObject.getString("selecteddeparts"); String selectedDeparts = jsonObject.getString("selecteddeparts");
System.out.println("我的测试"+selectedRoles);
try { try {
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
user.setCreateTime(new Date());//设置创建时间 user.setCreateTime(new Date());//设置创建时间
@ -206,8 +209,11 @@ public class SysUserController {
user.setPassword(passwordEncode); user.setPassword(passwordEncode);
user.setStatus(1); user.setStatus(1);
user.setDelFlag(CommonConstant.DEL_FLAG_0); user.setDelFlag(CommonConstant.DEL_FLAG_0);
//用户表字段org_code不能在这里设置他的值
user.setOrgCode(null);
// 保存用户走一个service 保证事务 // 保存用户走一个service 保证事务
sysUserService.saveUser(user, selectedRoles, selectedDeparts); sysUserService.saveUser(user, selectedRoles, selectedDeparts);
// baseCommonService.addLog("添加用户,username: " + user.getUsername(), CommonConstant.LOG_TYPE_2, 2);
result.success("添加成功!"); result.success("添加成功!");
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -218,6 +224,7 @@ public class SysUserController {
//@RequiresRoles({"admin"}) //@RequiresRoles({"admin"})
//@RequiresPermissions("user:edit") //@RequiresPermissions("user:edit")
@AutoLog
@RequestMapping(value = "/edit", method = RequestMethod.PUT) @RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) { public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
Result<SysUser> result = new Result<SysUser>(); Result<SysUser> result = new Result<SysUser>();
@ -234,6 +241,7 @@ public class SysUserController {
String roles = jsonObject.getString("selectedroles"); String roles = jsonObject.getString("selectedroles");
String departs = jsonObject.getString("selecteddeparts"); String departs = jsonObject.getString("selecteddeparts");
// 修改用户走一个service 保证事务 // 修改用户走一个service 保证事务
// sysUserService.updateById(user);
sysUserService.editUser(user, roles, departs); sysUserService.editUser(user, roles, departs);
result.success("修改成功!"); result.success("修改成功!");
} }
@ -248,10 +256,12 @@ public class SysUserController {
* 删除用户 * 删除用户
*/ */
//@RequiresRoles({"admin"}) //@RequiresRoles({"admin"})
@AutoLog
@RequestMapping(value = "/delete", method = RequestMethod.DELETE) @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
baseCommonService.addLog("删除用户,id: " +id ,CommonConstant.LOG_TYPE_2, 3); this.sysUserService.removeById(id);
this.sysUserService.deleteUser(id); // baseCommonService.addLog("删除用户,id: " + id, CommonConstant.LOG_TYPE_2, 3);
// this.sysUserService.deleteUser(id);
return Result.ok("删除用户成功"); return Result.ok("删除用户成功");
} }
@ -261,13 +271,14 @@ public class SysUserController {
//@RequiresRoles({"admin"}) //@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
baseCommonService.addLog("批量删除用户, ids: " +ids ,CommonConstant.LOG_TYPE_2, 3); // baseCommonService.addLog("批量删除用户, ids: " + ids, CommonConstant.LOG_TYPE_2, 3);
this.sysUserService.deleteBatchUsers(ids); this.sysUserService.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除用户成功"); return Result.ok("批量删除用户成功");
} }
/** /**
* 冻结&解冻用户 * 冻结&解冻用户
*
* @param jsonObject * @param jsonObject
* @return * @return
*/ */
@ -470,6 +481,7 @@ public class SysUserController {
/** /**
* 用户选择组件 专用 根据用户账号或部门分页查询 * 用户选择组件 专用 根据用户账号或部门分页查询
*
* @param departId * @param departId
* @param username * @param username
* @return * @return
@ -484,6 +496,7 @@ public class SysUserController {
IPage<SysUser> pageList = sysUserDepartService.queryDepartUserPageList(departId, username, realname, pageSize, pageNo); IPage<SysUser> pageList = sysUserDepartService.queryDepartUserPageList(departId, username, realname, pageSize, pageNo);
return Result.OK(pageList); return Result.OK(pageList);
} }
@RequestMapping(value = "/queryStudentComponentData", method = RequestMethod.GET) @RequestMapping(value = "/queryStudentComponentData", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryStudentComponentData( public Result<IPage<SysUser>> queryStudentComponentData(
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@ -610,9 +623,9 @@ public class SysUserController {
} }
/** /**
* @功能根据id 批量查询
* @param userIds * @param userIds
* @return * @return
* @功能根据id 批量查询
*/ */
@RequestMapping(value = "/queryByIds", method = RequestMethod.GET) @RequestMapping(value = "/queryByIds", method = RequestMethod.GET)
public Result<Collection<SysUser>> queryByIds(@RequestParam String userIds) { public Result<Collection<SysUser>> queryByIds(@RequestParam String userIds) {
@ -691,8 +704,10 @@ public class SysUserController {
return result; return result;
} }
} }
/** /**
* 删除指定角色的用户关系 * 删除指定角色的用户关系
*
* @param * @param
* @return * @return
*/ */
@ -931,6 +946,7 @@ public class SysUserController {
/** /**
* 查询当前用户的所有部门/当前部门编码 * 查询当前用户的所有部门/当前部门编码
*
* @return * @return
*/ */
@RequestMapping(value = "/getCurrentUserDeparts", method = RequestMethod.GET) @RequestMapping(value = "/getCurrentUserDeparts", method = RequestMethod.GET)
@ -952,8 +968,6 @@ public class SysUserController {
} }
/** /**
* 用户注册接口 * 用户注册接口
* *
@ -1033,6 +1047,7 @@ public class SysUserController {
/** /**
* 根据用户名或手机号查询用户信息 * 根据用户名或手机号查询用户信息
*
* @param * @param
* @return * @return
*/ */
@ -1177,6 +1192,7 @@ public class SysUserController {
/** /**
* APP端接口获取用户列表 根据用户名和真实名 模糊匹配 * APP端接口获取用户列表 根据用户名和真实名 模糊匹配
*
* @param keyword * @param keyword
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
@ -1269,6 +1285,7 @@ public class SysUserController {
/** /**
* 移动端修改用户信息 * 移动端修改用户信息
*
* @param jsonObject * @param jsonObject
* @return * @return
*/ */
@ -1323,8 +1340,10 @@ public class SysUserController {
} }
return result; return result;
} }
/** /**
* 移动端保存设备信息 * 移动端保存设备信息
*
* @param clientId * @param clientId
* @return * @return
*/ */
@ -1346,6 +1365,7 @@ public class SysUserController {
} }
return result; return result;
} }
/** /**
* 根据userid获取用户信息和部门员工信息 * 根据userid获取用户信息和部门员工信息
* *
@ -1370,8 +1390,10 @@ public class SysUserController {
} }
return Result.ok(map); return Result.ok(map);
} }
/** /**
* 移动端查询部门用户信息 * 移动端查询部门用户信息
*
* @param departId * @param departId
* @return * @return
*/ */
@ -1384,8 +1406,10 @@ public class SysUserController {
result.setResult(childrenUser); result.setResult(childrenUser);
return result; return result;
} }
/** /**
* 移动端查询用户信息(通过用户名模糊查询) * 移动端查询用户信息(通过用户名模糊查询)
*
* @param keyword * @param keyword
* @return * @return
*/ */
@ -1415,6 +1439,7 @@ public class SysUserController {
/** /**
* 根据用户名修改手机号 * 根据用户名修改手机号
*
* @param json * @param json
* @return * @return
*/ */

@ -169,6 +169,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
/** /**
* 通过用户名获取用户角色集合 * 通过用户名获取用户角色集合
*
* @param username 用户名 * @param username 用户名
* @return 角色集合 * @return 角色集合
*/ */
@ -248,10 +249,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username) { public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username) {
return userMapper.getUserByDepIds(page, departIds, username); return userMapper.getUserByDepIds(page, departIds, username);
} }
@Override @Override
public List<SysUser> getUserByDepIds(List<String> departIds, String username) { public List<SysUser> getUserByDepIds(List<String> departIds, String username) {
return userMapper.getUserByDepIds(departIds, username); return userMapper.getUserByDepIds(departIds, username);
} }
@Override @Override
public Map<String, String> getDepNamesByUserIds(List<String> userIds) { public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds); List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds);
@ -366,6 +369,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
/** /**
* 校验用户是否有效 * 校验用户是否有效
*
* @param sysUser * @param sysUser
* @return * @return
*/ */
@ -469,45 +473,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) { public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) {
//首先根据id看修改前有没有这个学生,如果有的话,调用edit修改,没有的话直接添加。
int ans=jxStudentService.cont(user.getId());
//step.1 保存用户 //step.1 保存用户
this.save(user); this.save(user);
//step.2 保存角色 //step.2 保存角色
if (oConvertUtils.isNotEmpty(selectedRoles)) { if (oConvertUtils.isNotEmpty(selectedRoles)) {
String[] arr = selectedRoles.split(","); String[] arr = selectedRoles.split(",");
for (String roleId : arr) { for (String roleId : arr) {
//这串数字是学生角色id
if(roleId.equals("1296245993988284417")){
JxStudent jxStudent=new JxStudent();
jxStudent.setId(user.getId());
jxStudent.setName(user.getRealname());
jxStudent.setPhone(user.getPhone());
jxStudent.setBirthday(user.getBirthday());
if(user.getSex()==1)
jxStudent.setSex("1");
else
jxStudent.setSex("2");
//这里的判断主要是为了防止学生表新加后再来用户表新加会出现的问题。
if(ans==0)
jxStudentService.save(jxStudent);
}
SysUserRole userRole = new SysUserRole(user.getId(), roleId); SysUserRole userRole = new SysUserRole(user.getId(), roleId);
sysUserRoleMapper.insert(userRole); sysUserRoleMapper.insert(userRole);
} }
} }
//step.3 保存所属部门 //step.3 保存所属部门
if (oConvertUtils.isNotEmpty(selectedDeparts)) { if (oConvertUtils.isNotEmpty(selectedDeparts)) {
ans=jxStudentService.cont(user.getId());
String[] arr = selectedDeparts.split(","); String[] arr = selectedDeparts.split(",");
System.out.println(arr.length);
for (String deaprtId : arr) { for (String deaprtId : arr) {
if(arr.length==1&&ans!=0){
JxStudent jxStudent=new JxStudent();
jxStudent.setId(user.getId());
jxStudent.setFaculty(deaprtId);
jxStudentService.updateById(jxStudent);
}
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId); SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId);
sysUserDepartMapper.insert(userDeaprt); sysUserDepartMapper.insert(userDeaprt);
} }
@ -518,49 +497,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true)
public void editUser(SysUser user, String roles, String departs) { public void editUser(SysUser user, String roles, String departs) {
//首先根据id看修改前有没有这个学生,如果有的话,调用edit修改,没有的话直接添加。
int ans=jxStudentService.cont(user.getId());
//ans不等于0的话,就是有这条数据,调用edit修改,否则就是添加。
//判断修改后,对应用户是否还有学生这个角色。
boolean student=false;
//step.1 修改用户基础信息 //step.1 修改用户基础信息
this.updateById(user); this.updateById(user);
//step.2 修改角色 //step.2 修改角色
//处理用户角色 先删后加 //处理用户角色 先删后加
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId()));
//这里if中判断的是否角色为空,为空直接不执行了,所以说,如果之前有学生的话,要给删掉的。
if (oConvertUtils.isNotEmpty(roles)) { if (oConvertUtils.isNotEmpty(roles)) {
String[] arr = roles.split(","); String[] arr = roles.split(",");
for (String roleId : arr) { for (String roleId : arr) {
//在修改用户角色时,如果没了学生这个角色,一会就要把对应学生表中的数据给删掉了。
if(roleId.equals("1296245993988284417")){
student=true;
JxStudent jxStudent=new JxStudent();
jxStudent.setId(user.getId());
jxStudent.setName(user.getRealname());
jxStudent.setPhone(user.getPhone());
jxStudent.setBirthday(user.getBirthday());
if(user.getSex()==1)
jxStudent.setSex("1");
else
jxStudent.setSex("2");
//判断是不是第一次给用户学生这个角色,如果是的话就会调用save新增,如果不是的话,就会在原表中进行修改。
if(ans==0)
jxStudentService.save(jxStudent);
else
jxStudentService.updateById(jxStudent);
}
SysUserRole userRole = new SysUserRole(user.getId(), roleId); SysUserRole userRole = new SysUserRole(user.getId(), roleId);
sysUserRoleMapper.insert(userRole); sysUserRoleMapper.insert(userRole);
} }
//如果student为false,则证明修改之后,没有学生这个角色了,要把学生表中对应的信息给删除。
if(!student&&ans!=0){
jxStudentService.removeById(user.getId());
} }
}else{
//修改完一个角色都没有,而且学生表还存在的话,就直接删除。
if(ans!=0)
jxStudentService.removeById(user.getId());}
//step.3 修改部门 //step.3 修改部门
String[] arr = {}; String[] arr = {};
@ -586,14 +534,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
//先删后加 //先删后加
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
if (oConvertUtils.isNotEmpty(departs)) { if (oConvertUtils.isNotEmpty(departs)) {
//ans=jxStudentService.cont(user.getId());
for (String departId : arr) { for (String departId : arr) {
if(arr.length==1&&ans!=0){
JxStudent jxStudent=new JxStudent();
jxStudent.setId(user.getId());
jxStudent.setFaculty(departId);
jxStudentService.updateById(jxStudent);
}
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); SysUserDepart userDepart = new SysUserDepart(user.getId(), departId);
sysUserDepartMapper.insert(userDepart); sysUserDepartMapper.insert(userDepart);
} }

@ -97,6 +97,12 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@ApiOperation(value="实体表-添加", notes="实体表-添加") @ApiOperation(value="实体表-添加", notes="实体表-添加")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<?> add(@RequestBody Tablex tablex) { public Result<?> add(@RequestBody Tablex tablex) {
List<Tablex> tablexList = tablexService.list();
for (Tablex tablex1 : tablexList){
if (tablex1.getModuleId().equals(tablex.getModuleId())){
return Result.error("该模块已有实体,添加失败");
}
}
if (tablex.getModuleId() != null){ if (tablex.getModuleId() != null){
Modulex modulex = modulexService.getById(tablex.getModuleId()); Modulex modulex = modulexService.getById(tablex.getModuleId());
tablex.setTableName(modulex.getModuleName()); tablex.setTableName(modulex.getModuleName());
@ -118,6 +124,12 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@ApiOperation(value="实体表-编辑", notes="实体表-编辑") @ApiOperation(value="实体表-编辑", notes="实体表-编辑")
@PutMapping(value = "/edit") @PutMapping(value = "/edit")
public Result<?> edit(@RequestBody Tablex tablex) { public Result<?> edit(@RequestBody Tablex tablex) {
List<Tablex> tablexList = tablexService.list();
for (Tablex tablex1 : tablexList){
if (tablex1.getModuleId().equals(tablex.getModuleId())){
return Result.error("该模块已有实体,编辑失败");
}
}
if (tablex.getModuleId() != null){ if (tablex.getModuleId() != null){
Modulex modulex = modulexService.getById(tablex.getModuleId()); Modulex modulex = modulexService.getById(tablex.getModuleId());
tablex.setTableName(modulex.getModuleName()); tablex.setTableName(modulex.getModuleName());

@ -169,7 +169,7 @@ mybatis-plus:
table-underline: true table-underline: true
configuration: configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段 # 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true call-setters-on-nulls: true
#jeecg专用配置 #jeecg专用配置

@ -168,7 +168,7 @@ mybatis-plus:
table-underline: true table-underline: true
configuration: configuration:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段 # 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true call-setters-on-nulls: true
#jeecg专用配置 #jeecg专用配置

Loading…
Cancel
Save