¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api.business; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.dao.business.model.BaseParam; |
| | | import com.doumee.service.business.BaseParamService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/07 15:19 |
| | | */ |
| | | @Api(tags = "ç³»ç»åºç¡é
置表") |
| | | @RestController |
| | | @RequestMapping("/business/baseParam") |
| | | public class BaseParamController extends BaseController { |
| | | |
| | | @Autowired |
| | | private BaseParamService baseParamService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | | @RequiresPermissions("business:baseparam:create") |
| | | public ApiResponse create(@RequestBody BaseParam baseParam) { |
| | | return ApiResponse.success(baseParamService.create(baseParam)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDå é¤") |
| | | @GetMapping("/delete/{id}") |
| | | @RequiresPermissions("business:baseparam:delete") |
| | | public ApiResponse deleteById(@PathVariable String id) { |
| | | baseParamService.deleteById(id); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| | | @RequiresPermissions("business:baseparam:delete") |
| | | public ApiResponse deleteByIdInBatch(@RequestParam String ids) { |
| | | String [] idArray = ids.split(","); |
| | | List<String> idList = new ArrayList<>(); |
| | | for (String id : idArray) { |
| | | idList.add(id); |
| | | } |
| | | baseParamService.deleteByIdInBatch(idList); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDä¿®æ¹") |
| | | @PostMapping("/updateById") |
| | | @RequiresPermissions("business:baseparam:update") |
| | | public ApiResponse updateById(@RequestBody BaseParam baseParam) { |
| | | baseParamService.updateById(baseParam); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @RequiresPermissions("business:baseparam:query") |
| | | public ApiResponse<PageData<BaseParam>> findPage (@RequestBody PageWrap<BaseParam> pageWrap) { |
| | | return ApiResponse.success(baseParamService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @RequiresPermissions("business:baseparam:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<BaseParam> pageWrap, HttpServletResponse response) { |
| | | ExcelExporter.build(BaseParam.class).export(baseParamService.findPage(pageWrap).getRecords(), "ç³»ç»åºç¡é
置表", response); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/{id}") |
| | | @RequiresPermissions("business:baseparam:query") |
| | | public ApiResponse findById(@PathVariable String id) { |
| | | return ApiResponse.success(baseParamService.findById(id)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:create', 'æ°å»ºç³»ç»åºç¡é
置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:delete', 'å é¤ç³»ç»åºç¡é
置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:update', 'ä¿®æ¹ç³»ç»åºç¡é
置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:query', 'æ¥è¯¢ç³»ç»åºç¡é
置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:exportExcel', '导åºç³»ç»åºç¡é
置表(Excel)', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.doumee.dao.business.model.BaseParam; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/07 15:19 |
| | | */ |
| | | public interface BaseParamMapper extends BaseMapper<BaseParam> { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * ç³»ç»åºç¡é
置表 |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/07 15:19 |
| | | */ |
| | | @Data |
| | | @ApiModel("ç³»ç»åºç¡é
置表") |
| | | @TableName("`base_param`") |
| | | public class BaseParam { |
| | | |
| | | @ApiModelProperty(value = "ç¼ç ") |
| | | @ExcelColumn(name="ç¼ç ") |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @ExcelColumn(name="å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date createDate; |
| | | |
| | | @ApiModelProperty(value = "å建人") |
| | | @ExcelColumn(name="å建人") |
| | | private String creator; |
| | | |
| | | @ApiModelProperty(value = "ç¼è¾æ¶é´") |
| | | @ExcelColumn(name="ç¼è¾æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date editDate; |
| | | |
| | | @ApiModelProperty(value = "ç¼è¾äºº") |
| | | @ExcelColumn(name="ç¼è¾äºº") |
| | | private String editor; |
| | | |
| | | @ApiModelProperty(value = "æ¯å¦å·²å é¤ 0æªå é¤ 1å·²å é¤", example = "1") |
| | | @ExcelColumn(name="æ¯å¦å·²å é¤ 0æªå é¤ 1å·²å é¤") |
| | | private Integer isdeleted; |
| | | |
| | | @ApiModelProperty(value = "åç§°") |
| | | @ExcelColumn(name="åç§°") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "æåºç ï¼ååºï¼", example = "1") |
| | | @ExcelColumn(name="æåºç ï¼ååºï¼") |
| | | private Integer sortnum; |
| | | |
| | | @ApiModelProperty(value = "ç±»å 0车è¾ä¿ä¿®åå 1强å¶è¿è½¦åå 2æ¶é¿åå
åå 3å车类å", example = "1") |
| | | @ExcelColumn(name="ç±»å 0车è¾ä¿ä¿®åå 1强å¶è¿è½¦åå 2æ¶é¿åå
åå 3å车类å") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty(value = "ç¶æ 0å¯ç¨ 1ç¦ç¨", example = "1") |
| | | @ExcelColumn(name="ç¶æ 0å¯ç¨ 1ç¦ç¨") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | @ExcelColumn(name="夿³¨") |
| | | private String info; |
| | | |
| | | @ApiModelProperty(value = "夿³¨æ¯å¦å¿
å¡« 0å¦ 1æ¯", example = "1") |
| | | @ExcelColumn(name="夿³¨æ¯å¦å¿
å¡« 0å¦ 1æ¯") |
| | | private Integer required; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.business.model.BaseParam; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç³»ç»åºç¡é
置表Serviceå®ä¹ |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/07 15:19 |
| | | */ |
| | | public interface BaseParamService { |
| | | |
| | | /** |
| | | * å建 |
| | | * |
| | | * @param baseParam å®ä½å¯¹è±¡ |
| | | * @return String |
| | | */ |
| | | String create(BaseParam baseParam); |
| | | |
| | | /** |
| | | * 主é®å é¤ |
| | | * |
| | | * @param id ä¸»é® |
| | | */ |
| | | void deleteById(String id); |
| | | |
| | | /** |
| | | * å é¤ |
| | | * |
| | | * @param baseParam å®ä½å¯¹è±¡ |
| | | */ |
| | | void delete(BaseParam baseParam); |
| | | |
| | | /** |
| | | * æ¹é主é®å é¤ |
| | | * |
| | | * @param ids 主é®é |
| | | */ |
| | | void deleteByIdInBatch(List<String> ids); |
| | | |
| | | /** |
| | | * 䏻鮿´æ° |
| | | * |
| | | * @param baseParam å®ä½å¯¹è±¡ |
| | | */ |
| | | void updateById(BaseParam baseParam); |
| | | |
| | | /** |
| | | * æ¹é䏻鮿´æ° |
| | | * |
| | | * @param baseParams å®ä½é |
| | | */ |
| | | void updateByIdInBatch(List<BaseParam> baseParams); |
| | | |
| | | /** |
| | | * 䏻鮿¥è¯¢ |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return BaseParam |
| | | */ |
| | | BaseParam findById(String id); |
| | | |
| | | /** |
| | | * æ¡ä»¶æ¥è¯¢åæ¡è®°å½ |
| | | * |
| | | * @param baseParam å®ä½å¯¹è±¡ |
| | | * @return BaseParam |
| | | */ |
| | | BaseParam findOne(BaseParam baseParam); |
| | | |
| | | /** |
| | | * æ¡ä»¶æ¥è¯¢ |
| | | * |
| | | * @param baseParam å®ä½å¯¹è±¡ |
| | | * @return List<BaseParam> |
| | | */ |
| | | List<BaseParam> findList(BaseParam baseParam); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢ |
| | | * |
| | | * @param pageWrap å页对象 |
| | | * @return PageData<BaseParam> |
| | | */ |
| | | PageData<BaseParam> findPage(PageWrap<BaseParam> pageWrap); |
| | | |
| | | /** |
| | | * æ¡ä»¶ç»è®¡ |
| | | * |
| | | * @param baseParam å®ä½å¯¹è±¡ |
| | | * @return long |
| | | */ |
| | | long count(BaseParam baseParam); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.BaseParamMapper; |
| | | import com.doumee.dao.business.model.BaseParam; |
| | | import com.doumee.service.business.BaseParamService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç³»ç»åºç¡é
置表Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/07 15:19 |
| | | */ |
| | | @Service |
| | | public class BaseParamServiceImpl implements BaseParamService { |
| | | |
| | | @Autowired |
| | | private BaseParamMapper baseParamMapper; |
| | | |
| | | @Override |
| | | public String create(BaseParam baseParam) { |
| | | baseParamMapper.insert(baseParam); |
| | | return baseParam.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | baseParamMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(BaseParam baseParam) { |
| | | UpdateWrapper<BaseParam> deleteWrapper = new UpdateWrapper<>(baseParam); |
| | | baseParamMapper.delete(deleteWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<String> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | baseParamMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(BaseParam baseParam) { |
| | | baseParamMapper.updateById(baseParam); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<BaseParam> baseParams) { |
| | | if (CollectionUtils.isEmpty(baseParams)) { |
| | | return; |
| | | } |
| | | for (BaseParam baseParam: baseParams) { |
| | | this.updateById(baseParam); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public BaseParam findById(String id) { |
| | | return baseParamMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public BaseParam findOne(BaseParam baseParam) { |
| | | QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam); |
| | | return baseParamMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<BaseParam> findList(BaseParam baseParam) { |
| | | QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam); |
| | | return baseParamMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<BaseParam> findPage(PageWrap<BaseParam> pageWrap) { |
| | | IPage<BaseParam> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<BaseParam> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(BaseParam::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(BaseParam::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(BaseParam::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(BaseParam::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getName() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getName, pageWrap.getModel().getName()); |
| | | } |
| | | if (pageWrap.getModel().getSortnum() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getSortnum, pageWrap.getModel().getSortnum()); |
| | | } |
| | | if (pageWrap.getModel().getType() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getType, pageWrap.getModel().getType()); |
| | | } |
| | | if (pageWrap.getModel().getStatus() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getStatus, pageWrap.getModel().getStatus()); |
| | | } |
| | | if (pageWrap.getModel().getInfo() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getInfo, pageWrap.getModel().getInfo()); |
| | | } |
| | | if (pageWrap.getModel().getRequired() != null) { |
| | | queryWrapper.lambda().eq(BaseParam::getRequired, pageWrap.getModel().getRequired()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(baseParamMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |
| | | @Override |
| | | public long count(BaseParam baseParam) { |
| | | QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam); |
| | | return baseParamMapper.selectCount(wrapper); |
| | | } |
| | | } |