forked from github/cool-admin-java
feat: 新增解锁接口
This commit is contained in:
@@ -40,6 +40,14 @@ public class AdminStockRecordController extends BaseController<StockRecordServic
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "解锁")
|
||||
@PostMapping("/unlock")
|
||||
public R<Void> unlock(@RequestBody JSONObject params) {
|
||||
Long id = params.getLong("id");
|
||||
service.unlock(id, CoolSecurityUtil.getCurrentUserId());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "恢复")
|
||||
@PostMapping("/restore")
|
||||
public R<Void> restore(@RequestBody JSONObject params) {
|
||||
|
||||
@@ -7,4 +7,5 @@ public interface StockRecordService extends BaseService<StockRecordEntity> {
|
||||
void archive(Long id, Long userId);
|
||||
void restore(Long id, Long userId);
|
||||
void lock(Long id, Long userId);
|
||||
void unlock(Long id, Long userId);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,15 @@ public class StockRecordServiceImpl extends BaseServiceImpl<StockRecordMapper, S
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlock(Long id, Long userId) {
|
||||
StockRecordEntity entity = getById(id);
|
||||
if (entity != null && entity.getUserId().equals(userId) && Boolean.TRUE.equals(entity.getLocked())) {
|
||||
entity.setLocked(false);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void archive(Long id, Long userId) {
|
||||
StockRecordEntity entity = getById(id);
|
||||
|
||||
Reference in New Issue
Block a user