fix: 测试
This commit is contained in:
@@ -14,20 +14,20 @@ import java.util.Date;
|
||||
@Data
|
||||
public class BaseDTO implements Serializable {
|
||||
|
||||
private String create_name;
|
||||
private String createName;
|
||||
|
||||
private String create_id;
|
||||
private String createId;
|
||||
|
||||
private String update_name;
|
||||
private String updateName;
|
||||
|
||||
private String update_id;
|
||||
private String updateId;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
private Date createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ public class BaseQuery<T> {
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_used;
|
||||
private String isUsed;
|
||||
/**
|
||||
* 创建时间范围查询
|
||||
*/
|
||||
private String start_time;
|
||||
private String end_time;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,20 +20,20 @@ import java.util.Map;
|
||||
*/
|
||||
public class R extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public R() {
|
||||
put("code", 0);
|
||||
put("msg", "success");
|
||||
}
|
||||
|
||||
|
||||
public static R error() {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
|
||||
public static R error(String msg) {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
|
||||
}
|
||||
|
||||
|
||||
public static R error(int code, String msg) {
|
||||
R r = new R();
|
||||
r.put("code", code);
|
||||
@@ -44,15 +44,16 @@ public class R extends HashMap<String, Object> {
|
||||
public static R ok(String msg) {
|
||||
R r = new R();
|
||||
r.put("msg", msg);
|
||||
r.put("code", 200);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
public static R ok(Map<String, Object> map) {
|
||||
R r = new R();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
public static R ok() {
|
||||
return new R();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.boge.common.base.TableDataInfo;
|
||||
import com.boge.common.exception.RRException;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.common.utils.R;
|
||||
import com.boge.modules.dept.dao.SysDept;
|
||||
import com.boge.modules.dept.dto.DeptQuery;
|
||||
import com.boge.modules.dept.service.ISysDeptService;
|
||||
@@ -77,28 +78,28 @@ public class DeptController {
|
||||
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysDept resources){
|
||||
public R create(@Validated @RequestBody SysDept resources){
|
||||
deptService.createDept(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
return R.ok("新增成功");
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysDept dept){
|
||||
if (dept.getPid() != null && dept.getDept_id().equals(dept.getPid())) {
|
||||
public R update(@Validated @RequestBody SysDept dept){
|
||||
if (dept.getPid() != null && dept.getDeptId().equals(dept.getPid())) {
|
||||
throw new RRException("ID不能为空");
|
||||
}
|
||||
deptService.updateDept(dept);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> deptIds){
|
||||
public R delete(@RequestBody Set<String> deptIds){
|
||||
if (CollectionUtils.isEmpty(deptIds)){
|
||||
return ResponseEntity.noContent().build();
|
||||
return R.error("请选择需要删除的部门");
|
||||
}
|
||||
deptService.delateDept(deptIds);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return R.ok("删除成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public class SysDept implements Serializable {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "dept_id", type = IdType.NONE)
|
||||
private String dept_id;
|
||||
@TableId( type = IdType.ASSIGN_ID)
|
||||
private String deptId;
|
||||
|
||||
/**
|
||||
* 上级部门
|
||||
@@ -39,7 +39,7 @@ public class SysDept implements Serializable {
|
||||
/**
|
||||
* 子部门数目
|
||||
*/
|
||||
private Integer sub_count;
|
||||
private Integer subCount;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
@@ -49,59 +49,59 @@ public class SysDept implements Serializable {
|
||||
/**
|
||||
* 中文名称
|
||||
*/
|
||||
private String zh_name;
|
||||
private String zhName;
|
||||
/**
|
||||
* 英文名称
|
||||
*/
|
||||
private String en_name;
|
||||
private String enName;
|
||||
|
||||
/**
|
||||
* 印尼名称
|
||||
*/
|
||||
private String in_name;
|
||||
private String inName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer dept_sort;
|
||||
private Integer deptSort;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Boolean is_used;
|
||||
private Boolean isUsed;
|
||||
|
||||
private String create_id;
|
||||
private String createId;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String create_name;
|
||||
private String createName;
|
||||
|
||||
private String update_id;
|
||||
private String updateId;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String update_name;
|
||||
private String updateName;
|
||||
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 部门编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
private String extId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ import java.util.List;
|
||||
@Setter
|
||||
public class DeptTree implements Serializable {
|
||||
|
||||
private String dept_id;
|
||||
private String deptId;
|
||||
|
||||
private String pid;
|
||||
|
||||
private String name;
|
||||
private String in_name;
|
||||
private String en_name;
|
||||
private String zh_name;
|
||||
private String inName;
|
||||
private String enName;
|
||||
private String zhName;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<DeptTree> children;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
trees.add(deptDTO);
|
||||
}
|
||||
for (DeptTree it : deptDtos) {
|
||||
if (it.getPid() != null && deptDTO.getDept_id().equals(it.getPid())) {
|
||||
if (it.getPid() != null && deptDTO.getDeptId().equals(it.getPid())) {
|
||||
isChild = true;
|
||||
if (deptDTO.getChildren() == null) {
|
||||
deptDTO.setChildren(new ArrayList<>());
|
||||
@@ -88,14 +88,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
if (query.getPid() == null){
|
||||
query.setPid_is_null(true);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIs_used()!=null){
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
query.setPid_is_null(null);
|
||||
}
|
||||
}
|
||||
Page page = this.page(pageQuery.build(SysDept.class), query.build());
|
||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIs_used()!=null){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHas_children(false) );
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
||||
}
|
||||
return page;
|
||||
}
|
||||
@@ -117,12 +117,12 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDept(SysDept dept) {
|
||||
if (dept == null ||StringUtils.isEmpty(dept.getDept_id())){
|
||||
if (dept == null ||StringUtils.isEmpty(dept.getDeptId())){
|
||||
return;
|
||||
}
|
||||
this.updateById(dept);
|
||||
//删除节点信息
|
||||
sysDeptMapper.updateSubCount(dept.getDept_id());
|
||||
sysDeptMapper.updateSubCount(dept.getDeptId());
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){
|
||||
sysDeptMapper.updateSubCount(dept.getPid());
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
verification(deptIds);
|
||||
Set<String> depts = new HashSet<>();
|
||||
Set<String> pids = new HashSet<>();
|
||||
List<SysDept> deptList = sysDeptMapper.selectList(new QueryWrapper<SysDept>().in("dept_id", deptIds));
|
||||
List<SysDept> deptList = sysDeptMapper.selectList(new QueryWrapper<SysDept>().in("deptId", deptIds));
|
||||
for (String deptId : deptIds) {
|
||||
depts.add(deptId);
|
||||
String allChild = sysDeptMapper.findAllChild(deptId);
|
||||
@@ -146,7 +146,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
depts.addAll(Arrays.asList(split));
|
||||
}
|
||||
}
|
||||
this.remove(new QueryWrapper<SysDept>().in("dept_id", depts));
|
||||
this.remove(new QueryWrapper<SysDept>().in("deptId", depts));
|
||||
deptList.forEach(dept -> {
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){sysDeptMapper.updateSubCount(dept.getPid());}
|
||||
});
|
||||
@@ -167,9 +167,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
public void createDept(SysDept dept) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
|
||||
dept.setCreate_id(String.valueOf(userEntity.getUserId()));
|
||||
dept.setCreate_name(userEntity.getUsername());
|
||||
dept.setCreate_time(new Date());
|
||||
dept.setCreateId(String.valueOf(userEntity.getUserId()));
|
||||
dept.setCreateName(userEntity.getUsername());
|
||||
dept.setCreateTime(new Date());
|
||||
this.save(dept);
|
||||
// 清理缓存
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){
|
||||
|
||||
@@ -34,15 +34,15 @@ import java.util.List;
|
||||
public class DeptVo extends BaseDTO implements Serializable {
|
||||
|
||||
|
||||
private String dept_id;
|
||||
private String deptId;
|
||||
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
private String extId;
|
||||
|
||||
|
||||
|
||||
private Integer dept_sort;
|
||||
private Integer deptSort;
|
||||
|
||||
|
||||
@NotBlank
|
||||
@@ -50,34 +50,34 @@ public class DeptVo extends BaseDTO implements Serializable {
|
||||
private String name;
|
||||
@NotBlank
|
||||
|
||||
private String zh_name;
|
||||
private String zhName;
|
||||
@NotBlank
|
||||
|
||||
private String en_name;
|
||||
private String enName;
|
||||
@NotBlank
|
||||
|
||||
private String in_name;
|
||||
private String inName;
|
||||
|
||||
@NotNull
|
||||
|
||||
private Boolean is_used;
|
||||
private Boolean isUsed;
|
||||
|
||||
|
||||
private Long pid;
|
||||
|
||||
|
||||
private Integer sub_count = 0;
|
||||
private Integer subCount = 0;
|
||||
/**
|
||||
* 前端显示
|
||||
*/
|
||||
private Boolean has_children =Boolean.FALSE;
|
||||
private Boolean hasChildren =Boolean.FALSE;
|
||||
|
||||
private List<DeptVo> children;
|
||||
|
||||
public void setSub_count(Integer sub_count) {
|
||||
this.sub_count = sub_count;
|
||||
if (sub_count >0){
|
||||
this.has_children =Boolean.TRUE;
|
||||
public void setSubCount(Integer subCount) {
|
||||
this.subCount = subCount;
|
||||
if (subCount >0){
|
||||
this.hasChildren =Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.boge.modules.dict.controller;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.boge.common.base.TableDataInfo;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.common.utils.R;
|
||||
import com.boge.modules.dict.dao.Dict;
|
||||
import com.boge.modules.dict.dto.DictQuery;
|
||||
import com.boge.modules.dict.service.ISysDictService;
|
||||
@@ -46,21 +47,21 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> create(@RequestBody Dict dict){
|
||||
public R create(@RequestBody Dict dict){
|
||||
dictService.create(dict);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
return R.ok("添加成功");
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> updateDict(@Validated @RequestBody Dict dto){
|
||||
public R updateDict(@Validated @RequestBody Dict dto){
|
||||
dictService.updateDict(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
|
||||
public R delete(@RequestBody Set<String> ids){
|
||||
dictService.deleteBatchByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return R.ok("删除成功");
|
||||
}
|
||||
|
||||
@GetMapping("/dictDetail")
|
||||
@@ -81,9 +82,9 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
@PostMapping("/dictDetail")
|
||||
public ResponseEntity<Object> createDetail(@RequestBody Dict resources){
|
||||
public R createDetail(@RequestBody Dict resources){
|
||||
dictService.createDetail(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
return R.ok("新增成功");
|
||||
}
|
||||
|
||||
@PutMapping("/dictDetail")
|
||||
@@ -93,9 +94,9 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/dictDetail/{id}")
|
||||
public ResponseEntity<Object> deleteDetail(@PathVariable String id){
|
||||
public R deleteDetail(@PathVariable String id){
|
||||
dictService.deleteDetail(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return R.ok("删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.boge.modules.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -26,8 +27,8 @@ public class Dict implements Serializable {
|
||||
/**
|
||||
* 字典标识
|
||||
*/
|
||||
@TableId(value = "dict_id")
|
||||
private String dict_id;
|
||||
@TableId( type = IdType.ASSIGN_ID)
|
||||
private String dictId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
@@ -52,12 +53,12 @@ public class Dict implements Serializable {
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private BigDecimal dict_sort;
|
||||
private BigDecimal dictSort;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dict_type;
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 参数1
|
||||
@@ -77,31 +78,31 @@ public class Dict implements Serializable {
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_id;
|
||||
private String createId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_name;
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_id;
|
||||
private String updateId;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_name;
|
||||
private String updateName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -60,15 +61,17 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
String date = DateUtil.now();
|
||||
List<Dict> oldDict = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>()
|
||||
.eq(ObjectUtil.isNotNull(dict.getCode()), Dict::getCode, dict.getCode()));
|
||||
if (ObjectUtil.isNotNull(oldDict))
|
||||
throw new RRException("无标签");
|
||||
dict.setDict_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dict.setCreate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setCreate_name(userEntity.getUsername());
|
||||
dict.setCreate_time(date);
|
||||
dict.setUpdate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setUpdate_name(userEntity.getUsername());
|
||||
dict.setUpdate_time(date);
|
||||
if (!oldDict.isEmpty()) {
|
||||
throw new RRException("已存在标签");
|
||||
}
|
||||
|
||||
dict.setCreateId(String.valueOf(userEntity.getUserId()));
|
||||
dict.setCreateName(userEntity.getUsername());
|
||||
dict.setCreateTime(date);
|
||||
dict.setUpdateId(String.valueOf(userEntity.getUserId()));
|
||||
dict.setUpdateName(userEntity.getUsername());
|
||||
dict.setUpdateTime(date);
|
||||
dict.setDictId(UUID.randomUUID().toString());
|
||||
sysDictMapper.insert(dict);
|
||||
}
|
||||
|
||||
@@ -76,13 +79,13 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDict(Dict dto) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
||||
Dict dict = sysDictMapper.selectById(dto.getDictId());
|
||||
if (ObjectUtil.isNull(dict)) {
|
||||
throw new RRException("无标签");
|
||||
}
|
||||
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dto.getCode()));
|
||||
if (ObjectUtil.isNotNull(dictList) && !dto.getCode().equals(dict.getCode()))
|
||||
throw new RRException("无标签");
|
||||
if (!dictList.isEmpty() && !dto.getCode().equals(dict.getCode()))
|
||||
throw new RRException("已存在同编码的标签");
|
||||
String currentUserId = String.valueOf(userEntity.getUserId());
|
||||
String currentNickName = userEntity.getNickname();
|
||||
// 根据code获取所有字典
|
||||
@@ -90,9 +93,9 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
dicts.forEach(di -> {
|
||||
di.setCode(dto.getCode());
|
||||
di.setName(dto.getName());
|
||||
di.setUpdate_id(currentUserId);
|
||||
di.setUpdate_name(currentNickName);
|
||||
di.setUpdate_time(DateUtil.now());
|
||||
di.setUpdateId(currentUserId);
|
||||
di.setUpdateName(currentNickName);
|
||||
di.setUpdateTime(DateUtil.now());
|
||||
sysDictMapper.updateById(di);
|
||||
});
|
||||
}
|
||||
@@ -113,7 +116,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
lam.eq(Dict::getCode, criteria.getCode())
|
||||
.isNotNull(Dict::getLabel)
|
||||
.ne(Dict::getLabel, "")
|
||||
.orderBy(true, true, Dict::getDict_sort);
|
||||
.orderBy(true, true, Dict::getDictSort);
|
||||
IPage<Dict> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
sysDictMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
@@ -144,8 +147,8 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
dic.setCode(dict.getCode());
|
||||
dic.setLabel(dict.getLabel());
|
||||
dic.setValue(dict.getValue());
|
||||
dic.setDict_sort(dict.getDict_sort());
|
||||
dic.setDict_type(dict.getDict_type());
|
||||
dic.setDictSort(dict.getDictSort());
|
||||
dic.setDictType(dict.getDictType());
|
||||
dic.setPara1(dict.getPara1());
|
||||
dic.setPara2(dict.getPara2());
|
||||
dic.setPara3(dict.getPara3());
|
||||
@@ -153,15 +156,15 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
return;
|
||||
}
|
||||
// 插入新的数据
|
||||
dict.setDict_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dict.setDictId(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dict.setCode(dic.getCode());
|
||||
dict.setName(dic.getName());
|
||||
dict.setCreate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setCreate_name(userEntity.getUsername());
|
||||
dict.setCreate_time(DateUtil.now());
|
||||
dict.setUpdate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setUpdate_name(userEntity.getUsername());
|
||||
dict.setUpdate_time(DateUtil.now());
|
||||
dict.setCreateId(String.valueOf(userEntity.getUserId()));
|
||||
dict.setCreateName(userEntity.getUsername());
|
||||
dict.setCreateTime(DateUtil.now());
|
||||
dict.setUpdateId(String.valueOf(userEntity.getUserId()));
|
||||
dict.setUpdateName(userEntity.getUsername());
|
||||
dict.setUpdateTime(DateUtil.now());
|
||||
sysDictMapper.insert(dict);
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDetail(Dict resources) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
Dict dict = sysDictMapper.selectById(resources.getDict_id());
|
||||
Dict dict = sysDictMapper.selectById(resources.getDictId());
|
||||
if (ObjectUtil.isNull(dict)) {
|
||||
throw new RRException("无标签");
|
||||
}
|
||||
@@ -179,9 +182,9 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
if (ObjectUtil.isNotNull(dictList) && !resources.getLabel().equals(dict.getLabel())) {
|
||||
throw new RRException("无标签");
|
||||
}
|
||||
resources.setUpdate_id(String.valueOf(userEntity.getUserId()));
|
||||
resources.setUpdate_name(userEntity.getUsername());
|
||||
resources.setUpdate_time(DateUtil.now());
|
||||
resources.setUpdateId(String.valueOf(userEntity.getUserId()));
|
||||
resources.setUpdateName(userEntity.getUsername());
|
||||
resources.setUpdateTime(DateUtil.now());
|
||||
sysDictMapper.updateById(resources);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FlwDeployController {
|
||||
|
||||
|
||||
/**
|
||||
* 发起流程
|
||||
* 流程查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ public class FlwInstanceController {
|
||||
private FlwInstanceService instanceService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* 发起流程
|
||||
*/
|
||||
@RequestMapping("/startFlowInstance")
|
||||
public R startFlowInstance(@RequestParam Map<String, Object> params){
|
||||
@@ -55,7 +55,7 @@ public class FlwInstanceController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的发起
|
||||
* 我的完成
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -182,6 +182,18 @@ public class FlwDeployServiceImpl extends FlowServiceNoFactory implements FlwDep
|
||||
// 从BpmnModel对象中获取相关的 userTask 信息
|
||||
Process mainProcess = bpmnModel.getMainProcess();
|
||||
Collection<FlowElement> flowElements = mainProcess.getFlowElements();
|
||||
sendflow(flowElements, list);
|
||||
// 获取所有的用户和所有的角色信息
|
||||
List<SysUserEntity> users = userService.list();
|
||||
List<SysRoleEntity> roles = roleService.list();
|
||||
return R.ok("获取数据成功")
|
||||
.put("data", list)
|
||||
.put("users", users)
|
||||
.put("roles", roles)
|
||||
;
|
||||
}
|
||||
|
||||
private void sendflow(Collection<FlowElement> flowElements, List<Map<String, Object>> list) {
|
||||
for (FlowElement flowElement : flowElements) {
|
||||
//System.out.println(flowElement.getName()+"" + flowElement);
|
||||
if (flowElement instanceof UserTask) {
|
||||
@@ -222,14 +234,6 @@ public class FlwDeployServiceImpl extends FlowServiceNoFactory implements FlwDep
|
||||
|
||||
}
|
||||
}
|
||||
// 获取所有的用户和所有的角色信息
|
||||
List<SysUserEntity> users = userService.list();
|
||||
List<SysRoleEntity> roles = roleService.list();
|
||||
return R.ok("获取数据成功")
|
||||
.put("data", list)
|
||||
.put("users", users)
|
||||
.put("roles", roles)
|
||||
;
|
||||
}
|
||||
|
||||
public String findFlowDefUserOrGroup(String str) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.boge.modules.flow.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.boge.common.exception.RRException;
|
||||
import com.boge.common.utils.Constant;
|
||||
import com.boge.common.utils.PageUtils;
|
||||
import com.boge.common.utils.R;
|
||||
@@ -14,6 +17,7 @@ import com.boge.modules.flow.service.FlwInstanceService;
|
||||
import com.boge.modules.sys.entity.SysUserEntity;
|
||||
import com.boge.modules.sys.service.SysRoleService;
|
||||
import com.boge.modules.sys.service.SysUserService;
|
||||
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
@@ -35,6 +39,12 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -46,14 +56,157 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
@Autowired
|
||||
private SysUserServiceImpl sysUserService;
|
||||
|
||||
//发送消息的类型
|
||||
private final static String MSGTYPE = "text";
|
||||
//将消息发送给所有成员
|
||||
private final static String TOPARTY = "@all";
|
||||
//获取企业微信的企业号,根据不同企业更改
|
||||
private final static String CORPID = "ww5aa8af6a525eae6e";
|
||||
//获取企业应用的密钥,根据不同应用更改
|
||||
private final static String CORPSECRET = "n6Vvnad69GxLfYlDS4hQaWuApwxFR36Wjq12eXNmi4M";
|
||||
//获取访问权限码URL
|
||||
private final static String ACCESS_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
|
||||
//创建会话请求URL
|
||||
private final static String CREATE_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void startFlowInstance(Map<String, Object> params) {
|
||||
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||
// 获取需要发起的流程信息
|
||||
String defId = (String) params.get("id");
|
||||
Map<String, Object> variable = new HashMap<>();
|
||||
// 结合传递过来的数据动态的绑定流程变量
|
||||
Set<String> keys = params.keySet();
|
||||
packageData(params, keys, variable);
|
||||
|
||||
// 记录流程的发起人
|
||||
identityService.setAuthenticatedUserId(ShiroUtils.getUserId().toString());
|
||||
// 启动流程
|
||||
runtimeService.startProcessInstanceById(defId, variable);
|
||||
SysUserEntity user = sysUserService.getById(Long.valueOf((String) params.get("user1")));
|
||||
if (StrUtil.isEmpty(user.getWexinId())){
|
||||
throw new RRException("企业id为空,企业微信消息无法推送");
|
||||
}
|
||||
|
||||
String accessToken = getAccessToken();
|
||||
sendWeChatMessage(user.getWexinId(),"工单已推送,请登入售后管理系统处理",accessToken);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取access_token
|
||||
*/
|
||||
|
||||
public static String getAccessToken() {
|
||||
//访问微信服务器
|
||||
String url = ACCESS_TOKEN_URL + "?corpid=" + CORPID + "&corpsecret=" + CORPSECRET;
|
||||
try {
|
||||
URL getUrl = new URL(url);
|
||||
//开启连接,并返回一个URLConnection对象
|
||||
HttpURLConnection http = (HttpURLConnection) getUrl.openConnection();
|
||||
http.setRequestMethod("GET");
|
||||
http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
|
||||
//将URL连接用于输入和输出,一般输入默认为true,输出默认为false
|
||||
http.setDoOutput(true);
|
||||
http.setDoInput(true);
|
||||
//进行连接,不返回对象
|
||||
http.connect();
|
||||
|
||||
//获得输入内容,并将其存储在缓存区
|
||||
InputStream inputStream = http.getInputStream();
|
||||
int size = inputStream.available();
|
||||
byte[] buffer = new byte[size];
|
||||
inputStream.read(buffer);
|
||||
//将内容转化为JSON代码
|
||||
String message = new String(buffer, "UTF-8");
|
||||
JSONObject json = JSONObject.parseObject(message);
|
||||
// token失效时间,需要避免频繁读取
|
||||
int timeOut = json.getInteger("expires_in");
|
||||
/* token.setAccess_token(json.getString("access_token"));
|
||||
token.setExpires_in(new Integer(json.getString("expires_in")));*/
|
||||
return json.getString("access_token");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//返回access_token码
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void sendWeChatMessage(String toUser, String content, String ACCESS_TOKEN) {
|
||||
//请求串
|
||||
String url = CREATE_SESSION_URL + ACCESS_TOKEN;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("touser", toUser);
|
||||
jsonObject.put("msgtype", "text");
|
||||
jsonObject.put("agentid", 1000006);
|
||||
JSONObject contentJSon = new JSONObject();
|
||||
contentJSon.put("content", content);
|
||||
jsonObject.put("text", contentJSon);
|
||||
jsonObject.put("safe", 0);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
URL postUrl = new URL(url);
|
||||
HttpURLConnection http = (HttpURLConnection) postUrl.openConnection();
|
||||
http.setRequestMethod("POST");
|
||||
http.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
http.setDoOutput(true);
|
||||
http.setDoInput(true);
|
||||
// 连接超时30秒
|
||||
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");
|
||||
// 读取超时30秒
|
||||
System.setProperty("sun.net.client.defaultReadTimeout", "30000");
|
||||
http.connect();
|
||||
|
||||
//写入内容
|
||||
OutputStream outputStream = http.getOutputStream();
|
||||
outputStream.write(jsonObject.toJSONString().getBytes("UTF-8"));
|
||||
InputStream inputStream = http.getInputStream();
|
||||
int size = inputStream.available();
|
||||
byte[] jsonBytes = new byte[size];
|
||||
inputStream.read(jsonBytes);
|
||||
String result = new String(jsonBytes, "UTF-8");
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
||||
int errcode = jsonObject1.getInteger("errcode");
|
||||
if (Objects.equals(42001, errcode)) {
|
||||
throw new RRException("发送企业微信 token 失效");
|
||||
}
|
||||
if (Objects.equals(0, errcode)) {
|
||||
System.out.println("消息发送成功");
|
||||
}
|
||||
System.out.println("请求返回结果:" + jsonObject1);
|
||||
|
||||
//清空输出流
|
||||
outputStream.flush();
|
||||
//关闭输出通道
|
||||
outputStream.close();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ProtocolException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void packageData(Map<String, Object> params, Set<String> keys, Map<String, Object> variable) {
|
||||
if(keys != null){
|
||||
for (String key : keys) {
|
||||
if("id".equals(key) || "t".equals(key)){
|
||||
@@ -81,11 +234,6 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
|
||||
}
|
||||
}
|
||||
}
|
||||
// 记录流程的发起人
|
||||
identityService.setAuthenticatedUserId(ShiroUtils.getUserId().toString());
|
||||
// 启动流程
|
||||
runtimeService.startProcessInstanceById(defId,variable);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.List;
|
||||
@TableName("sys_user")
|
||||
public class SysUserEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@@ -94,4 +94,6 @@ public class SysUserEntity implements Serializable {
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String wexinId;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user