|
@@ -0,0 +1,130 @@
|
|
|
+package com.txz.mall.web.mng;
|
|
|
+import com.txz.mall.core.Result;
|
|
|
+import com.txz.mall.model.MidFavorite;
|
|
|
+import com.txz.mall.service.MidFavoriteService;
|
|
|
+
|
|
|
+import com.txz.mall.core.ResultCode;
|
|
|
+
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
+import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+* Created by CodeGenerator on 2025/08/13.
|
|
|
+*/
|
|
|
+@Api(tags = "[后台]midFavorite管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mid/favorite")
|
|
|
+public class MidFavoriteController {
|
|
|
+
|
|
|
+ private static Logger log = LoggerFactory.getLogger(MidFavoriteController.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MidFavoriteService midFavoriteService;
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation(value = "midFavorite新增")
|
|
|
+ public Result add(@RequestBody MidFavorite midFavorite) {
|
|
|
+ if(midFavorite == null){
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ midFavorite.setCreateTime(new Date());
|
|
|
+// midFavorite.setCreateUserId(userId);
|
|
|
+ midFavoriteService.save(midFavorite);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新增对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @ApiOperation(value = "midFavorite删除")
|
|
|
+ public Result delete(@RequestParam Long id) {
|
|
|
+ if(id == null){
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ MidFavorite midFavorite = new MidFavorite();
|
|
|
+ midFavorite.setId(id);
|
|
|
+ midFavorite.setIsDelete(1);
|
|
|
+ midFavoriteService.update(midFavorite);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @ApiOperation(value = "midFavorite更新")
|
|
|
+ public Result update(@RequestBody MidFavorite midFavorite) {
|
|
|
+ if(midFavorite == null){
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if(midFavorite.getId() == null){
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ midFavorite.setUpdateTime(new Date());
|
|
|
+// midFavorite.setUpdateUserId(userId);
|
|
|
+ midFavoriteService.update(midFavorite);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("更新对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperation(value = "midFavorite获取详情")
|
|
|
+ public Result<MidFavorite> detail(@RequestParam Long id) {
|
|
|
+ if(id == null){
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ MidFavorite midFavorite = null;
|
|
|
+ try {
|
|
|
+ midFavorite = midFavoriteService.findById(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(midFavorite);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation(value = "midFavorite获取列表")
|
|
|
+ public Result<List<MidFavorite>> list(@Validated @RequestBody MidFavoriteDTO dto) {
|
|
|
+ PageHelper.startPage(dto.getPage(), dto.getSize());
|
|
|
+
|
|
|
+ Condition condition = new Condition(MidFavorite.class);
|
|
|
+ Criteria criteria = condition.createCriteria();
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
+ condition.setOrderByClause("create_time DESC");
|
|
|
+ PageInfo pageInfo = null;
|
|
|
+ try {
|
|
|
+ List<MidFavorite> list = midFavoriteService.findByCondition(condition);
|
|
|
+ pageInfo = new PageInfo(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(pageInfo);
|
|
|
+ }
|
|
|
+}
|