Commit 86b4cbee by 吴迪

【修改】投资计划、字典表相关代码

parent c9f2c1b7
package com.wangtian.modules.manage.controller; package com.wangtian.modules.manage.controller;
import cn.hutool.core.bean.BeanUtil;
import com.wangtian.common.annotation.SysLog;
import com.wangtian.common.utils.PageUtils; import com.wangtian.common.utils.PageUtils;
import com.wangtian.common.utils.R; import com.wangtian.common.utils.R;
import com.wangtian.common.validator.ValidatorUtils;
import com.wangtian.common.validator.group.AddGroup;
import com.wangtian.common.validator.group.UpdateGroup;
import com.wangtian.modules.manage.entity.InvestmentPlanEntity; import com.wangtian.modules.manage.entity.InvestmentPlanEntity;
import com.wangtian.modules.manage.form.InvestmentPlanForm;
import com.wangtian.modules.manage.service.InvestmentPlanService; import com.wangtian.modules.manage.service.InvestmentPlanService;
import com.wangtian.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -11,17 +18,16 @@ import java.util.Arrays; ...@@ -11,17 +18,16 @@ import java.util.Arrays;
import java.util.Map; import java.util.Map;
/** /**
* 投资计划管理表 * 投资计划管理表
* *
* @author wudi * @author wudi
* @email 632132852@qq.com * @email 632132852@qq.com
* @date 2023-07-16 08:23:26 * @date 2023-07-16 17:09:57
*/ */
@RestController @RestController
@RequestMapping("manage/investmentplan") @RequestMapping("manage/investmentplan")
public class InvestmentPlanController { public class InvestmentPlanController extends AbstractController {
@Autowired @Autowired
private InvestmentPlanService investmentPlanService; private InvestmentPlanService investmentPlanService;
...@@ -29,8 +35,8 @@ public class InvestmentPlanController { ...@@ -29,8 +35,8 @@ public class InvestmentPlanController {
* 列表 * 列表
*/ */
@RequestMapping("/list") @RequestMapping("/list")
// @RequiresPermissions("manage:investmentplan:list") //@RequiresPermissions("manage:investmentplan:list")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params) {
PageUtils page = investmentPlanService.queryPage(params); PageUtils page = investmentPlanService.queryPage(params);
return R.ok().put("data", page); return R.ok().put("data", page);
...@@ -42,42 +48,52 @@ public class InvestmentPlanController { ...@@ -42,42 +48,52 @@ public class InvestmentPlanController {
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
//@RequiresPermissions("manage:investmentplan:info") //@RequiresPermissions("manage:investmentplan:info")
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") String id) {
InvestmentPlanEntity investmentPlan = investmentPlanService.getById(id); InvestmentPlanEntity investmentPlan = investmentPlanService.getById(id);
return R.ok().put("data", investmentPlan); return R.ok().put("data", investmentPlan);
} }
/** /**
* 保存 * 保存
*/ */
@SysLog("保存投资计划管理")
@RequestMapping("/save") @RequestMapping("/save")
// @RequiresPermissions("manage:investmentplan:save") //@RequiresPermissions("manage:investmentplan:save")
public R save(@RequestBody InvestmentPlanEntity investmentPlan){ public R save(@RequestBody InvestmentPlanForm investmentPlan) {
investmentPlanService.save(investmentPlan); //校验参数
ValidatorUtils.validateEntity(investmentPlan, AddGroup.class);
//转化实体对象
InvestmentPlanEntity investmentPlanEntity = new InvestmentPlanEntity();
BeanUtil.copyProperties(investmentPlan, investmentPlanEntity);
investmentPlanService.saveInvestmentPlan(investmentPlanEntity, getUser());
return R.ok(); return R.ok();
} }
/** /**
* 修改 * 修改
*/ */
@SysLog("修改投资计划管理")
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("manage:investmentplan:update") //@RequiresPermissions("manage:investmentplan:update")
public R update(@RequestBody InvestmentPlanEntity investmentPlan){ public R update(@RequestBody InvestmentPlanForm investmentPlan) {
investmentPlanService.updateById(investmentPlan);
ValidatorUtils.validateEntity(investmentPlan, UpdateGroup.class);
//转化实体对象
InvestmentPlanEntity investmentPlanEntity = new InvestmentPlanEntity();
BeanUtil.copyProperties(investmentPlan, investmentPlanEntity);
investmentPlanService.updateInvestmentPlanById(investmentPlanEntity, getUser());
return R.ok(); return R.ok();
} }
/** /**
* 删除 * 删除
*/ */
@SysLog("删除投资计划管理")
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("manage:investmentplan:delete") //@RequiresPermissions("manage:investmentplan:delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody String[] ids) {
investmentPlanService.removeByIds(Arrays.asList(ids)); investmentPlanService.removeByIds(Arrays.asList(ids));
return R.ok(); return R.ok();
} }
......
...@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
* *
* @author wudi * @author wudi
* @email 632132852@qq.com * @email 632132852@qq.com
* @date 2023-07-16 08:23:26 * @date 2023-07-16 17:09:57
*/ */
@Mapper @Mapper
public interface InvestmentPlanDao extends BaseMapper<InvestmentPlanEntity> { public interface InvestmentPlanDao extends BaseMapper<InvestmentPlanEntity> {
......
package com.wangtian.modules.manage.entity; package com.wangtian.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import lombok.Data;
/** /**
* 投资计划管理表 * 投资计划管理表
* *
* @author wudi * @author wudi
* @email 632132852@qq.com * @email 632132852@qq.com
* @date 2023-07-16 08:23:26 * @date 2023-07-16 17:09:57
*/ */
@Data @Data
@TableName("pm_investment_plan") @TableName("pm_investment_plan")
...@@ -99,7 +98,6 @@ public class InvestmentPlanEntity implements Serializable { ...@@ -99,7 +98,6 @@ public class InvestmentPlanEntity implements Serializable {
* 是否删除 0/未删除,1/删除 * 是否删除 0/未删除,1/删除
*/ */
@TableLogic
private Integer isDelete; private Integer isDelete;
} }
package com.wangtian.modules.manage.form; package com.wangtian.modules.manage.form;
import com.wangtian.common.validator.group.AddGroup; import com.wangtian.common.validator.group.AddGroup;
import com.wangtian.common.validator.group.UpdateGroup; import com.wangtian.common.validator.group.UpdateGroup;
import lombok.Data; import lombok.Data;
...@@ -12,62 +11,63 @@ import java.math.BigDecimal; ...@@ -12,62 +11,63 @@ import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
* 投资计划管理表
*
* @author wudi * @author wudi
* @date 2023/7/16 * @email 632132852@qq.com
* @comment * @date 2023-07-16 17:09:57
*/ */
@Data @Data
public class InvestmentPlanForm implements Serializable { public class InvestmentPlanForm implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L; @NotNull(message = "投资计划ID不能为空",groups = { UpdateGroup.class})
private String id;
@NotNull(message = "投资计划ID不能为空",groups = { UpdateGroup.class})
private String id;
/** /**
* 投资计划名称 * 投资计划名称
*/ */
@NotBlank(message = "投资计划名称不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "投资计划名称不能为空",groups = {AddGroup.class, UpdateGroup.class})
private String planName; private String planName;
/** /**
* 投资计划类型,使用Java枚举类维护 * 投资计划类型,使用Java枚举类维护
*/ */
@NotBlank(message = "投资计划类型不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "投资计划类型不能为空",groups = {AddGroup.class, UpdateGroup.class})
private Integer planType; private Integer planType;
/** /**
* 年度 * 年度
*/ */
@NotBlank(message = "年度不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "年度不能为空",groups = {AddGroup.class, UpdateGroup.class})
private String planYear; private String planYear;
/** /**
* 批次 * 批次
*/ */
@NotBlank(message = "批次不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "批次不能为空",groups = {AddGroup.class, UpdateGroup.class})
private String planBatchNumber; private String planBatchNumber;
/** /**
* 计划文号 * 计划文号
*/ */
@NotBlank(message = "计划文号不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "计划文号不能为空",groups = {AddGroup.class, UpdateGroup.class})
private String planNumber; private String planNumber;
/** /**
* 资本性金额(万元) * 资本性金额(万元)
*/ */
@NotBlank(message = "资本性金额不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "资本性金额不能为空",groups = {AddGroup.class, UpdateGroup.class})
private BigDecimal planCapitalAmount; private BigDecimal planCapitalAmount;
/** /**
* 成本性金额(万元) * 成本性金额(万元)
*/ */
@NotBlank(message = "成本性金额不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "成本性金额不能为空",groups = {AddGroup.class, UpdateGroup.class})
private BigDecimal planCostAmount; private BigDecimal planCostAmount;
/** /**
* 投资计划下达时间 * 投资计划下达时间
*/ */
@NotBlank(message = "投资计划下达时间不能为空",groups = {AddGroup.class, UpdateGroup.class}) @NotBlank(message = "投资计划下达时间不能为空",groups = {AddGroup.class, UpdateGroup.class})
private Date planDeliveryTime; private Date planDeliveryTime;
/** /**
* 下达备注 * 下达备注
*/ */
private String planRemarks; private String planRemarks;
} }
...@@ -3,6 +3,8 @@ package com.wangtian.modules.manage.service; ...@@ -3,6 +3,8 @@ package com.wangtian.modules.manage.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.wangtian.common.utils.PageUtils; import com.wangtian.common.utils.PageUtils;
import com.wangtian.modules.manage.entity.InvestmentPlanEntity; import com.wangtian.modules.manage.entity.InvestmentPlanEntity;
import org.springframework.transaction.annotation.Transactional;
import com.wangtian.modules.sys.entity.SysUserEntity;
import java.util.Map; import java.util.Map;
...@@ -11,10 +13,16 @@ import java.util.Map; ...@@ -11,10 +13,16 @@ import java.util.Map;
* *
* @author wudi * @author wudi
* @email 632132852@qq.com * @email 632132852@qq.com
* @date 2023-07-16 08:23:26 * @date 2023-07-16 17:09:57
*/ */
public interface InvestmentPlanService extends IService<InvestmentPlanEntity> { public interface InvestmentPlanService extends IService<InvestmentPlanEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
@Transactional
void saveInvestmentPlan(InvestmentPlanEntity investmentPlanEntity, SysUserEntity loginUser);
@Transactional
void updateInvestmentPlanById(InvestmentPlanEntity investmentPlanEntity, SysUserEntity loginUser);
} }
...@@ -3,19 +3,28 @@ package com.wangtian.modules.manage.service.impl; ...@@ -3,19 +3,28 @@ package com.wangtian.modules.manage.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sitech.idworkstarter.IdWorkService;
import com.wangtian.common.utils.PageUtils; import com.wangtian.common.utils.PageUtils;
import com.wangtian.common.utils.Query; import com.wangtian.common.utils.Query;
import com.wangtian.modules.manage.dao.InvestmentPlanDao; import com.wangtian.modules.manage.dao.InvestmentPlanDao;
import com.wangtian.modules.manage.entity.InvestmentPlanEntity; import com.wangtian.modules.manage.entity.InvestmentPlanEntity;
import com.wangtian.modules.manage.service.InvestmentPlanService; import com.wangtian.modules.manage.service.InvestmentPlanService;
import com.wangtian.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map; import java.util.Map;
@Service("investmentPlanService") @Service("investmentPlanService")
public class InvestmentPlanServiceImpl extends ServiceImpl<InvestmentPlanDao, InvestmentPlanEntity> implements InvestmentPlanService { public class InvestmentPlanServiceImpl extends ServiceImpl<InvestmentPlanDao, InvestmentPlanEntity> implements InvestmentPlanService {
@Autowired
IdWorkService idWorkService;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<InvestmentPlanEntity> page = this.page( IPage<InvestmentPlanEntity> page = this.page(
...@@ -26,4 +35,22 @@ public class InvestmentPlanServiceImpl extends ServiceImpl<InvestmentPlanDao, In ...@@ -26,4 +35,22 @@ public class InvestmentPlanServiceImpl extends ServiceImpl<InvestmentPlanDao, In
return new PageUtils(page); return new PageUtils(page);
} }
@Override
public void updateInvestmentPlanById(InvestmentPlanEntity investmentPlanEntity, SysUserEntity loginUser) {
investmentPlanEntity.setUpdateTime(new Date());
investmentPlanEntity.setUpdateUserName(loginUser.getUsername());
investmentPlanEntity.setUpdateUserId(loginUser.getUserId());
baseMapper.updateById(investmentPlanEntity);
}
@Override
public void saveInvestmentPlan(InvestmentPlanEntity investmentPlanEntity, SysUserEntity loginUser) {
investmentPlanEntity.setId(idWorkService.getSEQByKey("id_seq"));
investmentPlanEntity.setCreateUserId(loginUser.getUserId());
investmentPlanEntity.setCreateUserName(loginUser.getUsername());
investmentPlanEntity.setCreateTime(new Date());
baseMapper.insert(investmentPlanEntity);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment