From 87a0ccb7ed3f0c9bfd856169ef03de136cd1047d Mon Sep 17 00:00:00 2001 From: tj <1378534974@qq.com> Date: 星期四, 20 三月 2025 09:07:39 +0800 Subject: [PATCH] 高级安全防护 --- src/main/java/com/jsh/erp/dto/ConfigSecurityQuery.java | 24 src/main/resources/mapper_xml/ConfigSecurityMapper.xml | 323 +++++++++ src/main/java/com/jsh/erp/datasource/entities/ConfigSecurityExample.java | 950 ++++++++++++++++++++++++++++ pom.xml | 9 src/main/java/com/jsh/erp/datasource/entities/ConfigSecurity.java | 125 +++ src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java | 24 src/main/java/com/jsh/erp/dto/PageQuery.java | 22 src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java | 16 src/main/resources/mapper_xml/SysDictItemMapper.xml | 3 src/main/java/com/jsh/erp/controller/SysDictController.java | 15 src/main/java/com/jsh/erp/controller/ConfigSecurityController.java | 190 +++++ src/main/java/com/jsh/erp/service/sys/impl/SysDictServiceImpl.java | 6 src/main/java/com/jsh/erp/datasource/mappers/ConfigSecurityMapper.java | 30 src/main/java/com/jsh/erp/datasource/mappers/SysDictItemMapper.java | 3 src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java | 29 src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java | 159 ++++ src/main/java/com/jsh/erp/service/sys/SysDictService.java | 9 17 files changed, 1,936 insertions(+), 1 deletions(-) diff --git a/pom.xml b/pom.xml index 937cab6..61b8be9 100644 --- a/pom.xml +++ b/pom.xml @@ -123,6 +123,15 @@ <artifactId>pinyin4j</artifactId> <version>2.5.1</version> </dependency> + + <!-- 分页插件 --> + <dependency> + <groupId>com.github.pagehelper</groupId> + <artifactId>pagehelper-spring-boot-starter</artifactId> + <version>1.2.3</version> + </dependency> + + </dependencies> <build> diff --git a/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java b/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java new file mode 100644 index 0000000..c0252e1 --- /dev/null +++ b/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java @@ -0,0 +1,190 @@ +package com.jsh.erp.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.jsh.erp.datasource.entities.SysDict; +import com.jsh.erp.dto.ConfigSecurityCreateOrUpdate; +import com.jsh.erp.dto.ConfigSecurityQuery; +import com.jsh.erp.datasource.entities.ConfigSecurity; +import com.jsh.erp.service.configSecurity.ConfigSecurityService; +import com.jsh.erp.utils.BaseResponseInfo; +import com.jsh.erp.utils.ErpInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; + +/** + * @author ji sheng hua jshERP + */ +@RestController +@RequestMapping(value = "/config-security") +@Api(tags = {"高级安全防护管理"}) +public class ConfigSecurityController { + private Logger logger = LoggerFactory.getLogger(ConfigSecurityController.class); + + @Resource + private ConfigSecurityService configSecurityService; + + + /** + * 高级安全防护列表 + * @param currentPage + * @param pageSize + * @param type + * @param keyword + * @param request + * @return + * @throws Exception + */ +// @GetMapping(value = "/list") +// @ApiOperation(value = "高级安全防护列表") +// public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage, +// @RequestParam("pageSize") Integer pageSize, +// @RequestParam(value = "type", required = false) String type , +// @RequestParam(value = "keyword", required = false) String keyword, +// HttpServletRequest request) throws Exception{ +// ConfigSecurityQuery configSecurityQuery = new ConfigSecurityQuery(keyword,type, null, null, null, null); +// configSecurityQuery.setCurrentPage(currentPage); +// configSecurityQuery.setPageSize(pageSize); +// BaseResponseInfo res = new BaseResponseInfo(); +// Map<String, Object> map = new HashMap<String, Object>(); +// try { +// List<ConfigSecurity> dataList = configSecurityService.findList(configSecurityQuery); +// Long total = configSecurityService.findListCount(configSecurityQuery); +// map.put("total", total); +// map.put("rows", dataList); +// res.code = 200; +// res.data = map; +// } catch(Exception e){ +// logger.error(e.getMessage(), e); +// res.code = 500; +// res.data = "获取数据失败"; +// } +// return res; +// } + + + @GetMapping(value = "/list") + @ApiOperation(value = "高级安全防护列表") + public BaseResponseInfo findAccountInOutList(ConfigSecurityQuery configSecurityQuery, + HttpServletRequest request) throws Exception{ + BaseResponseInfo res = new BaseResponseInfo(); + Map<String, Object> map = new HashMap<String, Object>(); + try { + List<ConfigSecurity> dataList = configSecurityService.findList(configSecurityQuery); + Long total = configSecurityService.findListCount(configSecurityQuery); + map.put("total", total); + map.put("rows", dataList); + res.code = 200; + res.data = map; + } catch(Exception e){ + logger.error(e.getMessage(), e); + res.code = 500; + res.data = "获取数据失败"; + } + return res; + } + + + @PostMapping + public BaseResponseInfo add(@RequestBody @Valid ConfigSecurityCreateOrUpdate configSecurityCreateOrUpdate) { + ConfigSecurity configSecurity = new ConfigSecurity(); + BeanUtils.copyProperties(configSecurityCreateOrUpdate, configSecurity); + BaseResponseInfo baseResponseInfo = new BaseResponseInfo(); + try { + int result = configSecurityService.add(configSecurity); + if(result > 0) { + baseResponseInfo.code = 200; + baseResponseInfo.msg = "新增成功"; + } + } catch(Exception e) { + baseResponseInfo.code = 500; + baseResponseInfo.msg = e.getMessage(); + } + return baseResponseInfo; + } + + @PutMapping + public BaseResponseInfo update(@RequestBody @Valid ConfigSecurityCreateOrUpdate configSecurityCreateOrUpdate) { + ConfigSecurity configSecurity = new ConfigSecurity(); + BaseResponseInfo baseResponseInfo = new BaseResponseInfo(); + try { + int result = configSecurityService.update(configSecurity); + if(result > 0) { + baseResponseInfo.code = 200; + baseResponseInfo.msg = "修改成功"; + } + } catch(Exception e) { + baseResponseInfo.code = 500; + baseResponseInfo.msg = e.getMessage(); + } + return baseResponseInfo; + } + + @DeleteMapping("/delete/{id}") + public BaseResponseInfo delete(@PathVariable Long id) { + BaseResponseInfo baseResponseInfo = new BaseResponseInfo(); + try { + int result = configSecurityService.deleteById(id); + if(result > 0) { + baseResponseInfo.code = 200; + baseResponseInfo.msg = "删除成功"; + } + } catch(Exception e) { + baseResponseInfo.code = 500; + baseResponseInfo.msg = e.getMessage(); + } + return baseResponseInfo; + } + + @DeleteMapping("/deleteBatch") + public BaseResponseInfo deleteBatch(@RequestParam("ids") String ids) { + BaseResponseInfo baseResponseInfo = new BaseResponseInfo(); + + try { + int result= configSecurityService.deleteBatch(ids); + if(result > 0) { + baseResponseInfo.code = 200; + baseResponseInfo.msg = "删除成功"; + } + } catch(Exception e) { + baseResponseInfo.code = 500; + baseResponseInfo.msg = e.getMessage(); + } + return baseResponseInfo; + } + + + /** + * 批量设置状态-启用或者禁用 + * @param jsonObject + * @param request + * @return + */ + @PostMapping(value = "/batchSetStatus") + @ApiOperation(value = "批量设置状态") + public String batchSetStatus(@RequestBody JSONObject jsonObject, + HttpServletRequest request)throws Exception { + Integer status = jsonObject.getInteger("status"); + String ids = jsonObject.getString("ids"); + Map<String, Object> objectMap = new HashMap<>(); + int res = configSecurityService.batchSetStatus(status, ids); + if(res > 0) { + return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + } else { + return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + } + } +} diff --git a/src/main/java/com/jsh/erp/controller/SysDictController.java b/src/main/java/com/jsh/erp/controller/SysDictController.java index f137897..e76fdf6 100644 --- a/src/main/java/com/jsh/erp/controller/SysDictController.java +++ b/src/main/java/com/jsh/erp/controller/SysDictController.java @@ -140,6 +140,21 @@ return baseResponseInfo; } + // 字典项相关接口 + @GetMapping("/items/dict-code/{dictCode}") + public BaseResponseInfo getItems(@PathVariable String dictCode) { + BaseResponseInfo baseResponseInfo = new BaseResponseInfo(); + try { + List<SysDictItem> items = sysDictService.getItemsBySictCode(dictCode); + baseResponseInfo.code = 200; + baseResponseInfo.data = items; + } catch(Exception e) { + baseResponseInfo.code = 500; + baseResponseInfo.msg = e.getMessage(); + } + return baseResponseInfo; + } + @PostMapping("/item") public BaseResponseInfo addItem(@RequestBody SysDictItem sysDictItem) { BaseResponseInfo baseResponseInfo = new BaseResponseInfo(); diff --git a/src/main/java/com/jsh/erp/datasource/entities/ConfigSecurity.java b/src/main/java/com/jsh/erp/datasource/entities/ConfigSecurity.java new file mode 100644 index 0000000..08682e8 --- /dev/null +++ b/src/main/java/com/jsh/erp/datasource/entities/ConfigSecurity.java @@ -0,0 +1,125 @@ +package com.jsh.erp.datasource.entities; + +import java.util.Date; + +public class ConfigSecurity { + private Long id; + + private String keyword; + + private String type; + + private String description; + + private Integer sortOrder; + + private Integer status; + + private Boolean deleteFlag; + + private Date createTime; + + private Long creator; + + private Date updateTime; + + private Long updater; + + private Long tenantId; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword == null ? null : keyword.trim(); + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type == null ? null : type.trim(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description == null ? null : description.trim(); + } + + public Integer getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Integer sortOrder) { + this.sortOrder = sortOrder; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Boolean getDeleteFlag() { + return deleteFlag; + } + + public void setDeleteFlag(Boolean deleteFlag) { + this.deleteFlag = deleteFlag; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Long getCreator() { + return creator; + } + + public void setCreator(Long creator) { + this.creator = creator; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Long getUpdater() { + return updater; + } + + public void setUpdater(Long updater) { + this.updater = updater; + } + + public Long getTenantId() { + return tenantId; + } + + public void setTenantId(Long tenantId) { + this.tenantId = tenantId; + } +} \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/datasource/entities/ConfigSecurityExample.java b/src/main/java/com/jsh/erp/datasource/entities/ConfigSecurityExample.java new file mode 100644 index 0000000..3f74d6b --- /dev/null +++ b/src/main/java/com/jsh/erp/datasource/entities/ConfigSecurityExample.java @@ -0,0 +1,950 @@ +package com.jsh.erp.datasource.entities; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class ConfigSecurityExample { + protected String orderByClause; + + protected boolean distinct; + + protected List<Criteria> oredCriteria; + + public ConfigSecurityExample() { + oredCriteria = new ArrayList<>(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List<Criteria> getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List<Criterion> criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List<Criterion> getAllCriteria() { + return criteria; + } + + public List<Criterion> getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List<Long> values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List<Long> values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andKeywordIsNull() { + addCriterion("keyword is null"); + return (Criteria) this; + } + + public Criteria andKeywordIsNotNull() { + addCriterion("keyword is not null"); + return (Criteria) this; + } + + public Criteria andKeywordEqualTo(String value) { + addCriterion("keyword =", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordNotEqualTo(String value) { + addCriterion("keyword <>", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordGreaterThan(String value) { + addCriterion("keyword >", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordGreaterThanOrEqualTo(String value) { + addCriterion("keyword >=", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordLessThan(String value) { + addCriterion("keyword <", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordLessThanOrEqualTo(String value) { + addCriterion("keyword <=", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordLike(String value) { + addCriterion("keyword like", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordNotLike(String value) { + addCriterion("keyword not like", value, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordIn(List<String> values) { + addCriterion("keyword in", values, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordNotIn(List<String> values) { + addCriterion("keyword not in", values, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordBetween(String value1, String value2) { + addCriterion("keyword between", value1, value2, "keyword"); + return (Criteria) this; + } + + public Criteria andKeywordNotBetween(String value1, String value2) { + addCriterion("keyword not between", value1, value2, "keyword"); + return (Criteria) this; + } + + public Criteria andTypeIsNull() { + addCriterion("type is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("type is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(String value) { + addCriterion("type =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(String value) { + addCriterion("type <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(String value) { + addCriterion("type >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(String value) { + addCriterion("type >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(String value) { + addCriterion("type <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(String value) { + addCriterion("type <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLike(String value) { + addCriterion("type like", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotLike(String value) { + addCriterion("type not like", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List<String> values) { + addCriterion("type in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List<String> values) { + addCriterion("type not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(String value1, String value2) { + addCriterion("type between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(String value1, String value2) { + addCriterion("type not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List<String> values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List<String> values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andSortOrderIsNull() { + addCriterion("sort_order is null"); + return (Criteria) this; + } + + public Criteria andSortOrderIsNotNull() { + addCriterion("sort_order is not null"); + return (Criteria) this; + } + + public Criteria andSortOrderEqualTo(Integer value) { + addCriterion("sort_order =", value, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderNotEqualTo(Integer value) { + addCriterion("sort_order <>", value, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderGreaterThan(Integer value) { + addCriterion("sort_order >", value, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderGreaterThanOrEqualTo(Integer value) { + addCriterion("sort_order >=", value, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderLessThan(Integer value) { + addCriterion("sort_order <", value, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderLessThanOrEqualTo(Integer value) { + addCriterion("sort_order <=", value, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderIn(List<Integer> values) { + addCriterion("sort_order in", values, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderNotIn(List<Integer> values) { + addCriterion("sort_order not in", values, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderBetween(Integer value1, Integer value2) { + addCriterion("sort_order between", value1, value2, "sortOrder"); + return (Criteria) this; + } + + public Criteria andSortOrderNotBetween(Integer value1, Integer value2) { + addCriterion("sort_order not between", value1, value2, "sortOrder"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("status is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("status is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Boolean value) { + addCriterion("status =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Boolean value) { + addCriterion("status <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Boolean value) { + addCriterion("status >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Boolean value) { + addCriterion("status >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Boolean value) { + addCriterion("status <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Boolean value) { + addCriterion("status <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List<Boolean> values) { + addCriterion("status in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List<Boolean> values) { + addCriterion("status not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Boolean value1, Boolean value2) { + addCriterion("status between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Boolean value1, Boolean value2) { + addCriterion("status not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andDeleteFlagIsNull() { + addCriterion("delete_flag is null"); + return (Criteria) this; + } + + public Criteria andDeleteFlagIsNotNull() { + addCriterion("delete_flag is not null"); + return (Criteria) this; + } + + public Criteria andDeleteFlagEqualTo(Boolean value) { + addCriterion("delete_flag =", value, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagNotEqualTo(Boolean value) { + addCriterion("delete_flag <>", value, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagGreaterThan(Boolean value) { + addCriterion("delete_flag >", value, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagGreaterThanOrEqualTo(Boolean value) { + addCriterion("delete_flag >=", value, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagLessThan(Boolean value) { + addCriterion("delete_flag <", value, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagLessThanOrEqualTo(Boolean value) { + addCriterion("delete_flag <=", value, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagIn(List<Boolean> values) { + addCriterion("delete_flag in", values, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagNotIn(List<Boolean> values) { + addCriterion("delete_flag not in", values, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagBetween(Boolean value1, Boolean value2) { + addCriterion("delete_flag between", value1, value2, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andDeleteFlagNotBetween(Boolean value1, Boolean value2) { + addCriterion("delete_flag not between", value1, value2, "deleteFlag"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List<Date> values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List<Date> values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreatorIsNull() { + addCriterion("creator is null"); + return (Criteria) this; + } + + public Criteria andCreatorIsNotNull() { + addCriterion("creator is not null"); + return (Criteria) this; + } + + public Criteria andCreatorEqualTo(Long value) { + addCriterion("creator =", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotEqualTo(Long value) { + addCriterion("creator <>", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorGreaterThan(Long value) { + addCriterion("creator >", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorGreaterThanOrEqualTo(Long value) { + addCriterion("creator >=", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorLessThan(Long value) { + addCriterion("creator <", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorLessThanOrEqualTo(Long value) { + addCriterion("creator <=", value, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorIn(List<Long> values) { + addCriterion("creator in", values, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotIn(List<Long> values) { + addCriterion("creator not in", values, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorBetween(Long value1, Long value2) { + addCriterion("creator between", value1, value2, "creator"); + return (Criteria) this; + } + + public Criteria andCreatorNotBetween(Long value1, Long value2) { + addCriterion("creator not between", value1, value2, "creator"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Date value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Date value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Date value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Date value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Date value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List<Date> values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List<Date> values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Date value1, Date value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Date value1, Date value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdaterIsNull() { + addCriterion("updater is null"); + return (Criteria) this; + } + + public Criteria andUpdaterIsNotNull() { + addCriterion("updater is not null"); + return (Criteria) this; + } + + public Criteria andUpdaterEqualTo(Long value) { + addCriterion("updater =", value, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterNotEqualTo(Long value) { + addCriterion("updater <>", value, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterGreaterThan(Long value) { + addCriterion("updater >", value, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterGreaterThanOrEqualTo(Long value) { + addCriterion("updater >=", value, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterLessThan(Long value) { + addCriterion("updater <", value, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterLessThanOrEqualTo(Long value) { + addCriterion("updater <=", value, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterIn(List<Long> values) { + addCriterion("updater in", values, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterNotIn(List<Long> values) { + addCriterion("updater not in", values, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterBetween(Long value1, Long value2) { + addCriterion("updater between", value1, value2, "updater"); + return (Criteria) this; + } + + public Criteria andUpdaterNotBetween(Long value1, Long value2) { + addCriterion("updater not between", value1, value2, "updater"); + return (Criteria) this; + } + + public Criteria andTenantIdIsNull() { + addCriterion("tenant_id is null"); + return (Criteria) this; + } + + public Criteria andTenantIdIsNotNull() { + addCriterion("tenant_id is not null"); + return (Criteria) this; + } + + public Criteria andTenantIdEqualTo(Long value) { + addCriterion("tenant_id =", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdNotEqualTo(Long value) { + addCriterion("tenant_id <>", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdGreaterThan(Long value) { + addCriterion("tenant_id >", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdGreaterThanOrEqualTo(Long value) { + addCriterion("tenant_id >=", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdLessThan(Long value) { + addCriterion("tenant_id <", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdLessThanOrEqualTo(Long value) { + addCriterion("tenant_id <=", value, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdIn(List<Long> values) { + addCriterion("tenant_id in", values, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdNotIn(List<Long> values) { + addCriterion("tenant_id not in", values, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdBetween(Long value1, Long value2) { + addCriterion("tenant_id between", value1, value2, "tenantId"); + return (Criteria) this; + } + + public Criteria andTenantIdNotBetween(Long value1, Long value2) { + addCriterion("tenant_id not between", value1, value2, "tenantId"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List<?>) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/datasource/mappers/ConfigSecurityMapper.java b/src/main/java/com/jsh/erp/datasource/mappers/ConfigSecurityMapper.java new file mode 100644 index 0000000..a2d6cf3 --- /dev/null +++ b/src/main/java/com/jsh/erp/datasource/mappers/ConfigSecurityMapper.java @@ -0,0 +1,30 @@ +package com.jsh.erp.datasource.mappers; + +import com.jsh.erp.datasource.entities.ConfigSecurity; +import com.jsh.erp.datasource.entities.ConfigSecurityExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface ConfigSecurityMapper { + long countByExample(ConfigSecurityExample example); + + int deleteByExample(ConfigSecurityExample example); + + int deleteByPrimaryKey(Long id); + + int insert(ConfigSecurity record); + + int insertSelective(ConfigSecurity record); + + List<ConfigSecurity> selectByExample(ConfigSecurityExample example); + + ConfigSecurity selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") ConfigSecurity record, @Param("example") ConfigSecurityExample example); + + int updateByExample(@Param("record") ConfigSecurity record, @Param("example") ConfigSecurityExample example); + + int updateByPrimaryKeySelective(ConfigSecurity record); + + int updateByPrimaryKey(ConfigSecurity record); +} \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/datasource/mappers/SysDictItemMapper.java b/src/main/java/com/jsh/erp/datasource/mappers/SysDictItemMapper.java index d720a17..d9fb79f 100644 --- a/src/main/java/com/jsh/erp/datasource/mappers/SysDictItemMapper.java +++ b/src/main/java/com/jsh/erp/datasource/mappers/SysDictItemMapper.java @@ -2,6 +2,7 @@ import com.jsh.erp.datasource.entities.SysDictItem; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -23,4 +24,6 @@ //通过字典类型和字典code查询具体一条 @Select("SELECT * FROM sys_dict_item di LEFT JOIN sys_dict d ON di.dict_id = d.id WHERE d.dict_code = #{dictCode} AND di.item_text = #{itemText}") SysDictItem getByDictCodeAndItemText(String dictCode, String itemText); + + List<SysDictItem> getItemsByDictCode(@Param("dictCode") String dictCode); } diff --git a/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java b/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java new file mode 100644 index 0000000..1057621 --- /dev/null +++ b/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java @@ -0,0 +1,29 @@ +package com.jsh.erp.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.Max; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ConfigSecurityCreateOrUpdate { + + private Long id; + + @NotEmpty(message = "关键字不能为空") + @Max(value = 50, message = "关键字长度不能超过50") + private String keyword; + + @NotEmpty(message = "类型不能为空") + private String type; + + @NotNull(message = "状态不能为空") + private Integer status; + + +} diff --git a/src/main/java/com/jsh/erp/dto/ConfigSecurityQuery.java b/src/main/java/com/jsh/erp/dto/ConfigSecurityQuery.java new file mode 100644 index 0000000..b41cc50 --- /dev/null +++ b/src/main/java/com/jsh/erp/dto/ConfigSecurityQuery.java @@ -0,0 +1,24 @@ +package com.jsh.erp.dto; + +import com.jsh.erp.datasource.entities.ConfigSecurity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ConfigSecurityQuery extends PageQuery { + + private String keyword; + + private String type; + + private String description; + + private Integer sortOrder; + + private Boolean status; + + private Boolean deleteFlag; +} diff --git a/src/main/java/com/jsh/erp/dto/PageQuery.java b/src/main/java/com/jsh/erp/dto/PageQuery.java new file mode 100644 index 0000000..810417e --- /dev/null +++ b/src/main/java/com/jsh/erp/dto/PageQuery.java @@ -0,0 +1,22 @@ +package com.jsh.erp.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.web.bind.annotation.RequestParam; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PageQuery { + + /** + * 当前页面 + */ + private Integer currentPage; + /** + * 每页显示条数 + */ + private Integer pageSize; + +} diff --git a/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java b/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java index 5cc0b58..03eb931 100644 --- a/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java @@ -3,11 +3,14 @@ import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.ExceptionConstants; import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestControllerAdvice; import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.stream.Collectors; @Slf4j @RestControllerAdvice @@ -32,6 +35,19 @@ return status; } + // 这里针对校验org.springframework.web.bind.MethodArgumentNotValidException 异常的处置 + if (e instanceof MethodArgumentNotValidException) { + status.put(ExceptionConstants.GLOBAL_RETURNS_CODE, 400); + List<String> errorMessages = ((MethodArgumentNotValidException) e).getBindingResult().getFieldErrors() + .stream() + .map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage()) + .collect(Collectors.toList()); + + // 以 JSON 数组形式返回 + status.put(ExceptionConstants.GLOBAL_RETURNS_MESSAGE, errorMessages); + return status; + } + status.put(ExceptionConstants.GLOBAL_RETURNS_CODE, ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE); status.put(ExceptionConstants.GLOBAL_RETURNS_DATA, ExceptionConstants.SERVICE_SYSTEM_ERROR_MSG); log.error("Global Exception Occured => url : {}, msg : {}", request.getRequestURL(), e.getMessage()); diff --git a/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java b/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java new file mode 100644 index 0000000..2070ed0 --- /dev/null +++ b/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java @@ -0,0 +1,24 @@ +package com.jsh.erp.service.configSecurity; + +import com.jsh.erp.datasource.entities.ConfigSecurity; +import com.jsh.erp.dto.ConfigSecurityQuery; + +import java.util.List; + +public interface ConfigSecurityService { + + + Long findListCount(ConfigSecurityQuery configSecurityQuery); + + List<ConfigSecurity> findList(ConfigSecurityQuery configSecurityQuery); + + int add(ConfigSecurity configSecurity); + + int update(ConfigSecurity configSecurity); + + int deleteById(Long id); + + int deleteBatch(String ids); + + int batchSetStatus(Integer status, String ids) throws Exception; +} diff --git a/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java b/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java new file mode 100644 index 0000000..45d1a62 --- /dev/null +++ b/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java @@ -0,0 +1,159 @@ +package com.jsh.erp.service.configSecurity.impl; + +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.github.pagehelper.PageHelper; +import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.datasource.entities.ConfigSecurity; +import com.jsh.erp.datasource.entities.ConfigSecurityExample; +import com.jsh.erp.datasource.mappers.ConfigSecurityMapper; +import com.jsh.erp.dto.ConfigSecurityQuery; +import com.jsh.erp.exception.JshException; +import com.jsh.erp.service.account.AccountService; +import com.jsh.erp.service.configSecurity.ConfigSecurityService; +import com.jsh.erp.service.log.LogService; +import com.jsh.erp.utils.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +@Service +public class ConfigSecurityServiceImpl implements ConfigSecurityService { + + private Logger logger = LoggerFactory.getLogger(AccountService.class); + + @Resource + private ConfigSecurityMapper configSecurityMapper; + + @Resource + private LogService logService; + + @Override + public Long findListCount(ConfigSecurityQuery configSecurityQuery) { + ConfigSecurityExample example = new ConfigSecurityExample(); + ConfigSecurityExample.Criteria criteria = example.createCriteria(); + criteria.andDeleteFlagEqualTo(false); + if (StringUtils.isNotEmpty(configSecurityQuery.getKeyword())) { + criteria.andKeywordLike("%" + configSecurityQuery.getKeyword() + "%"); + } + if (StringUtils.isNotEmpty(configSecurityQuery.getType())) { + criteria.andTypeEqualTo(configSecurityQuery.getType()); + } + + return configSecurityMapper.countByExample(example); + } + + @Override + public List<ConfigSecurity> findList(ConfigSecurityQuery configSecurityQuery) { + // 设置分页参数 + PageHelper.startPage(configSecurityQuery.getCurrentPage()-1, configSecurityQuery.getPageSize()); + + ConfigSecurityExample example = new ConfigSecurityExample(); + ConfigSecurityExample.Criteria criteria = example.createCriteria(); + criteria.andDeleteFlagEqualTo(false); + if (StringUtils.isNotEmpty(configSecurityQuery.getKeyword())) { + criteria.andKeywordLike("%" + configSecurityQuery.getKeyword() + "%"); + } + if (StringUtils.isNotEmpty(configSecurityQuery.getType())) { + criteria.andTypeEqualTo(configSecurityQuery.getType()); + } + + example.setOrderByClause(" create_time desc "); + + return configSecurityMapper.selectByExample(example); + } + + @Transactional + @Override + public int add(ConfigSecurity configSecurity) { + configSecurity.setDeleteFlag(false); + + extractedKeywordExists(configSecurity.getKeyword(),null); + + return configSecurityMapper.insert(configSecurity); + } + + private void extractedKeywordExists(String keyword, Long id) { + // 查看关键字是否已经存在 + ConfigSecurityExample example = new ConfigSecurityExample(); + ConfigSecurityExample.Criteria criteria = example.createCriteria(); + criteria.andDeleteFlagEqualTo(false); + criteria.andKeywordEqualTo(keyword); + if(!Objects.isNull(id)){ + criteria.andIdNotEqualTo(id); + } + long keywordExistedCnt = configSecurityMapper.countByExample(example); + if(keywordExistedCnt>0) + throw new RuntimeException("关键词已经存在"); + } + + @Transactional + @Override + public int update(ConfigSecurity configSecurity) { + extractedKeywordExists(configSecurity.getKeyword(),configSecurity.getId()); + + return configSecurityMapper.updateByPrimaryKeySelective(configSecurity); + } + + @Transactional + @Override + public int deleteById(Long id) { + ConfigSecurity configSecurity = configSecurityMapper.selectByPrimaryKey(id); + configSecurity.setDeleteFlag(true); + return configSecurityMapper.updateByPrimaryKeySelective(configSecurity); +// return configSecurityMapper.deleteByPrimaryKey(id); + } + + @Transactional + @Override + public int deleteBatch(String ids) { + + ConfigSecurity configSecurity = new ConfigSecurity(); + configSecurity.setDeleteFlag(true); + + ConfigSecurityExample example=new ConfigSecurityExample(); + ConfigSecurityExample.Criteria criteria=example.createCriteria(); + List<Long> configSecurityIds = StringUtil.strToLongList(ids); + criteria.andIdIn(configSecurityIds); + int result=0; + try{ + result = configSecurityMapper.updateByExampleSelective(configSecurity, example); + }catch(Exception e){ + JshException.writeFail(logger, e); + } + return result; + } + + @Transactional(value = "transactionManager", rollbackFor = Exception.class) + @Override + public int batchSetStatus(Integer status, String ids) throws Exception { + + logService.insertLog("账户", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ENABLED).toString(), + ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); + + ConfigSecurity configSecurity = new ConfigSecurity(); + configSecurity.setStatus(status); + + ConfigSecurityExample example=new ConfigSecurityExample(); + ConfigSecurityExample.Criteria criteria=example.createCriteria(); + List<Long> configSecurityIds = StringUtil.strToLongList(ids); + criteria.andIdIn(configSecurityIds); + int result=0; + try{ + result = configSecurityMapper.updateByExampleSelective(configSecurity, example); + }catch(Exception e){ + JshException.writeFail(logger, e); + } + return result; + } + + +} diff --git a/src/main/java/com/jsh/erp/service/sys/SysDictService.java b/src/main/java/com/jsh/erp/service/sys/SysDictService.java index 798cfb2..3104434 100644 --- a/src/main/java/com/jsh/erp/service/sys/SysDictService.java +++ b/src/main/java/com/jsh/erp/service/sys/SysDictService.java @@ -30,4 +30,11 @@ int deleteItemById(Long id); SysDictItem getByDictCodeAndItemText(String dictCode, String itemText); -} \ No newline at end of file + + /** + * 根据字典编码获取字典项 + * @param dictCode + * @return + */ + List<SysDictItem> getItemsBySictCode(String dictCode); +} \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/service/sys/impl/SysDictServiceImpl.java b/src/main/java/com/jsh/erp/service/sys/impl/SysDictServiceImpl.java index 0ab1310..c4ad965 100644 --- a/src/main/java/com/jsh/erp/service/sys/impl/SysDictServiceImpl.java +++ b/src/main/java/com/jsh/erp/service/sys/impl/SysDictServiceImpl.java @@ -9,6 +9,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; @Service @@ -80,4 +81,9 @@ public SysDictItem getByDictCodeAndItemText(String dictCode, String itemText) { return sysDictItemMapper.getByDictCodeAndItemText(dictCode, itemText); } + + @Override + public List<SysDictItem> getItemsBySictCode(String dictCode) { + return sysDictItemMapper.getItemsByDictCode(dictCode); + } } \ No newline at end of file diff --git a/src/main/resources/mapper_xml/ConfigSecurityMapper.xml b/src/main/resources/mapper_xml/ConfigSecurityMapper.xml new file mode 100644 index 0000000..e714ee6 --- /dev/null +++ b/src/main/resources/mapper_xml/ConfigSecurityMapper.xml @@ -0,0 +1,323 @@ +<?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="com.jsh.erp.datasource.mappers.ConfigSecurityMapper"> + <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.ConfigSecurity"> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="keyword" jdbcType="VARCHAR" property="keyword" /> + <result column="type" jdbcType="VARCHAR" property="type" /> + <result column="description" jdbcType="VARCHAR" property="description" /> + <result column="sort_order" jdbcType="INTEGER" property="sortOrder" /> + <result column="status" jdbcType="BIT" property="status" /> + <result column="delete_flag" jdbcType="BIT" property="deleteFlag" /> + <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> + <result column="creator" jdbcType="BIGINT" property="creator" /> + <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> + <result column="updater" jdbcType="BIGINT" property="updater" /> + <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> + </resultMap> + <sql id="Example_Where_Clause"> + <where> + <foreach collection="oredCriteria" item="criteria" separator="or"> + <if test="criteria.valid"> + <trim prefix="(" prefixOverrides="and" suffix=")"> + <foreach collection="criteria.criteria" item="criterion"> + <choose> + <when test="criterion.noValue"> + and ${criterion.condition} + </when> + <when test="criterion.singleValue"> + and ${criterion.condition} #{criterion.value} + </when> + <when test="criterion.betweenValue"> + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + </when> + <when test="criterion.listValue"> + and ${criterion.condition} + <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> + #{listItem} + </foreach> + </when> + </choose> + </foreach> + </trim> + </if> + </foreach> + </where> + </sql> + <sql id="Update_By_Example_Where_Clause"> + <where> + <foreach collection="example.oredCriteria" item="criteria" separator="or"> + <if test="criteria.valid"> + <trim prefix="(" prefixOverrides="and" suffix=")"> + <foreach collection="criteria.criteria" item="criterion"> + <choose> + <when test="criterion.noValue"> + and ${criterion.condition} + </when> + <when test="criterion.singleValue"> + and ${criterion.condition} #{criterion.value} + </when> + <when test="criterion.betweenValue"> + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + </when> + <when test="criterion.listValue"> + and ${criterion.condition} + <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> + #{listItem} + </foreach> + </when> + </choose> + </foreach> + </trim> + </if> + </foreach> + </where> + </sql> + <sql id="Base_Column_List"> + id, keyword, type, description, sort_order, status, delete_flag, create_time, creator, + update_time, updater, tenant_id + </sql> + <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.ConfigSecurityExample" resultMap="BaseResultMap"> + select + <if test="distinct"> + distinct + </if> + <include refid="Base_Column_List" /> + from config_security + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + <if test="orderByClause != null"> + order by ${orderByClause} + </if> + </select> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from config_security + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + delete from config_security + where id = #{id,jdbcType=BIGINT} + </delete> + <delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.ConfigSecurityExample"> + delete from config_security + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + </delete> + <insert id="insert" parameterType="com.jsh.erp.datasource.entities.ConfigSecurity"> + insert into config_security (id, keyword, type, + description, sort_order, status, + delete_flag, create_time, creator, + update_time, updater, tenant_id + ) + values (#{id,jdbcType=BIGINT}, #{keyword,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{sortOrder,jdbcType=INTEGER}, #{status,jdbcType=BIT}, + #{deleteFlag,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, #{creator,jdbcType=BIGINT}, + #{updateTime,jdbcType=TIMESTAMP}, #{updater,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT} + ) + </insert> + <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.ConfigSecurity"> + insert into config_security + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="keyword != null"> + keyword, + </if> + <if test="type != null"> + type, + </if> + <if test="description != null"> + description, + </if> + <if test="sortOrder != null"> + sort_order, + </if> + <if test="status != null"> + status, + </if> + <if test="deleteFlag != null"> + delete_flag, + </if> + <if test="createTime != null"> + create_time, + </if> + <if test="creator != null"> + creator, + </if> + <if test="updateTime != null"> + update_time, + </if> + <if test="updater != null"> + updater, + </if> + <if test="tenantId != null"> + tenant_id, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="keyword != null"> + #{keyword,jdbcType=VARCHAR}, + </if> + <if test="type != null"> + #{type,jdbcType=VARCHAR}, + </if> + <if test="description != null"> + #{description,jdbcType=VARCHAR}, + </if> + <if test="sortOrder != null"> + #{sortOrder,jdbcType=INTEGER}, + </if> + <if test="status != null"> + #{status,jdbcType=BIT}, + </if> + <if test="deleteFlag != null"> + #{deleteFlag,jdbcType=BIT}, + </if> + <if test="createTime != null"> + #{createTime,jdbcType=TIMESTAMP}, + </if> + <if test="creator != null"> + #{creator,jdbcType=BIGINT}, + </if> + <if test="updateTime != null"> + #{updateTime,jdbcType=TIMESTAMP}, + </if> + <if test="updater != null"> + #{updater,jdbcType=BIGINT}, + </if> + <if test="tenantId != null"> + #{tenantId,jdbcType=BIGINT}, + </if> + </trim> + </insert> + <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.ConfigSecurityExample" resultType="java.lang.Long"> + select count(*) from config_security + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + </select> + <update id="updateByExampleSelective" parameterType="map"> + update config_security + <set> + <if test="record.id != null"> + id = #{record.id,jdbcType=BIGINT}, + </if> + <if test="record.keyword != null"> + keyword = #{record.keyword,jdbcType=VARCHAR}, + </if> + <if test="record.type != null"> + type = #{record.type,jdbcType=VARCHAR}, + </if> + <if test="record.description != null"> + description = #{record.description,jdbcType=VARCHAR}, + </if> + <if test="record.sortOrder != null"> + sort_order = #{record.sortOrder,jdbcType=INTEGER}, + </if> + <if test="record.status != null"> + status = #{record.status,jdbcType=BIT}, + </if> + <if test="record.deleteFlag != null"> + delete_flag = #{record.deleteFlag,jdbcType=BIT}, + </if> + <if test="record.createTime != null"> + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + </if> + <if test="record.creator != null"> + creator = #{record.creator,jdbcType=BIGINT}, + </if> + <if test="record.updateTime != null"> + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + </if> + <if test="record.updater != null"> + updater = #{record.updater,jdbcType=BIGINT}, + </if> + <if test="record.tenantId != null"> + tenant_id = #{record.tenantId,jdbcType=BIGINT}, + </if> + </set> + <if test="_parameter != null"> + <include refid="Update_By_Example_Where_Clause" /> + </if> + </update> + <update id="updateByExample" parameterType="map"> + update config_security + set id = #{record.id,jdbcType=BIGINT}, + keyword = #{record.keyword,jdbcType=VARCHAR}, + type = #{record.type,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + sort_order = #{record.sortOrder,jdbcType=INTEGER}, + status = #{record.status,jdbcType=BIT}, + delete_flag = #{record.deleteFlag,jdbcType=BIT}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + creator = #{record.creator,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + updater = #{record.updater,jdbcType=BIGINT}, + tenant_id = #{record.tenantId,jdbcType=BIGINT} + <if test="_parameter != null"> + <include refid="Update_By_Example_Where_Clause" /> + </if> + </update> + <update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.ConfigSecurity"> + update config_security + <set> + <if test="keyword != null"> + keyword = #{keyword,jdbcType=VARCHAR}, + </if> + <if test="type != null"> + type = #{type,jdbcType=VARCHAR}, + </if> + <if test="description != null"> + description = #{description,jdbcType=VARCHAR}, + </if> + <if test="sortOrder != null"> + sort_order = #{sortOrder,jdbcType=INTEGER}, + </if> + <if test="status != null"> + status = #{status,jdbcType=BIT}, + </if> + <if test="deleteFlag != null"> + delete_flag = #{deleteFlag,jdbcType=BIT}, + </if> + <if test="createTime != null"> + create_time = #{createTime,jdbcType=TIMESTAMP}, + </if> + <if test="creator != null"> + creator = #{creator,jdbcType=BIGINT}, + </if> + <if test="updateTime != null"> + update_time = #{updateTime,jdbcType=TIMESTAMP}, + </if> + <if test="updater != null"> + updater = #{updater,jdbcType=BIGINT}, + </if> + <if test="tenantId != null"> + tenant_id = #{tenantId,jdbcType=BIGINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.ConfigSecurity"> + update config_security + set keyword = #{keyword,jdbcType=VARCHAR}, + type = #{type,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + sort_order = #{sortOrder,jdbcType=INTEGER}, + status = #{status,jdbcType=BIT}, + delete_flag = #{deleteFlag,jdbcType=BIT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + creator = #{creator,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + updater = #{updater,jdbcType=BIGINT}, + tenant_id = #{tenantId,jdbcType=BIGINT} + where id = #{id,jdbcType=BIGINT} + </update> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper_xml/SysDictItemMapper.xml b/src/main/resources/mapper_xml/SysDictItemMapper.xml index 52caa3b..da2f74c 100644 --- a/src/main/resources/mapper_xml/SysDictItemMapper.xml +++ b/src/main/resources/mapper_xml/SysDictItemMapper.xml @@ -10,6 +10,9 @@ <select id="selectById" resultType="com.jsh.erp.datasource.entities.SysDictItem"> select * from sys_dict_item where id = #{id} </select> + <select id="getItemsByDictCode" resultType="com.jsh.erp.datasource.entities.SysDictItem"> + select * from sys_dict_item where dict_id = (select id from sys_dict where dict_code = #{dictCode}) + </select> <insert id="insert" parameterType="com.jsh.erp.datasource.entities.SysDictItem"> insert into sys_dict_item -- Gitblit v1.9.3